I am attempting to extract some data from various tables in a web page. I've decided to use the WebBrowser control and DOM to get to the data. I'm struggling with the correct data types to use to access of the results of the DOM methods.

The following code snippet is intended to simply print the number of tables on a web page, and then the size of each table. The first print works, but none of the following do (the exception get's thrown).

I believe the problem is that objTable is simply an object, not a collection of objects.

VB Code:
  1. Private Sub DumpTables()
  2.       Dim x As Integer
  3.       Dim i, j, k As Integer
  4.       Dim s As String
  5.       Dim objTable As Object
  6.       Dim ObjDoc As Object
  7.  
  8.       ' wbrBrowser is the WebBrowser Control on the main form.
  9.       ObjDoc = wbrBrowser.Document
  10.  
  11.       Try
  12.          objTable = wbrBrowser.Document.getElementsByTagName("TABLE")
  13.          x = objTable.length
  14.          Debug.WriteLine("Number of Tables " & x)
  15.  
  16.  
  17.          For i = 0 To x - 1
  18.             j = objTable(0).length
  19.             Debug.WriteLine("Table: all: " & j _
  20.                & " Rows: " & objTable(i).rows.length _
  21.                & " Cols: " & objTable(i).cols)
  22.          Next
  23.  
  24.       Catch ex As Exception
  25.          MessageBox.Show("It is likely that your submit does not exist or has no name attribute. Check the HTML source.", "No name att. or no submit available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  26.       End Try
  27.  
  28.    End Sub

Here is a link to the MSDN document that describes the DOM.

It seems like I'm very close to understanding this, but can't figure out what types to use so VB can interpret the results from the DOM calls.

Any pointers or ideas would be appreciated.