Question Use MSHTML to get Column count in a Table


Active member
Mar 31, 2009
Programming Experience
Hello everyone. I have been experimenting with using MSHTML to parse HTML documents, in order to retreive data from those documents. First, take a look at the following peice of code:

Dim doc As HTMLDocument = New HTMLDocument()
Dim d2 As IHTMLDocument = doc

'strHTMLCode contains the html code of the imported document

Dim tableElements As IHTMLElementCollection
tableElements = d2.getElementsByTagName("TABLE")

get the 17th table in the document
Dim oTableTest As IHTMLTable = tableElements.item(16)
Dim intRowCount as Integer = oTableTest.rows.length
Basically this code gets the 17th table in the HTML document and then is able to get a count of the rows in that table.

My question: How do I get a count of columns for the same table, I have tried oTableTest.cols, bu there is no Lenght property and the value of oTableTest.cols is 0 (zero).

Can anyone give me any ideas as to how I can get the column count for a table via MSHTML?
Top Bottom