(Edit: VS 2010)
Hi to all
I'm in the process of migrating some code from VB6 to VB.NET and one of my routines is a simple MSXML page request that i then load into a HTMLDocument for parsing. The old VB6 code was almost compliant with VB.NET and is as follow:
I just had to convert it to this:
My problem is that the code in VB6 take about 20 seconds, most of it getting the page. The VB.NET code takes almost 5 minutes, about the same to get the page and load it in the parser. Almost all the time is lost while looping the table and retrieving the rows.
I have searched a lot trying to understand whats slowing it down but im a newbie in VB.Net and maybe im missing something more simple and fundamental.
Any help would be much appreciated.
Hi to all
I'm in the process of migrating some code from VB6 to VB.NET and one of my routines is a simple MSXML page request that i then load into a HTMLDocument for parsing. The old VB6 code was almost compliant with VB.NET and is as follow:
Code:
Public Sub GetPageAndParse()
Dim XMLHttpRequest As XMLHTTP, HtmlDoc As New HTMLDocument, Table As HTMLTable
Dim Row As HTMLTableRow, NumberOfRows As Integer, i As Integer
Set XMLHttpRequest = New MSXML2.XMLHTTP
XMLHttpRequest.Open "GET", "Some Page URL", False
XMLHttpRequest.send
HtmlDoc.Body.innerHTML = XMLHttpRequest.responseText
Set Table = HtmlDoc.getElementById("A Table")
If Not Table Is Nothing Then
NumberOfRows = Table.rows.length
For i = 0 To NumberOfRows - 1
Set Row = Table.rows(i)
Next
End If
End Sub
Code:
imports MSHTML
imports MSXML2
Module TXOdds
Public Sub GetPageAndParse()
Dim XMLHttpRequest As MSXML2.XMLHTTP, HtmlDoc As MSHTML.IHTMLDocument2, Table As MSHTML.HTMLTable
XMLHttpRequest = New MSXML2.XMLHTTP, NumberOfRows as Integer, i as Integer, Row As HTMLTableRow
XMLHttpRequest.open("GET", "Some Page URL", False)
XMLHttpRequest.send()
HtmlDoc = New MSHTML.HTMLDocument
HtmlDoc.Write (XMLHttpRequest.responseText)
Table = HtmlDoc.getElementById("A Table")
If Not Table Is Nothing Then
NumberOfRows = Table.rows.length
For i = 0 To NumberOfRows - 1
Set Row = Table.rows(i)
Next
End If
End Sub
End Module
I have searched a lot trying to understand whats slowing it down but im a newbie in VB.Net and maybe im missing something more simple and fundamental.
Any help would be much appreciated.