covert code vb to vb.net problem

Mr.Kim 1 Reputation point
2021-04-29T12:32:56.927+00:00

Hi all

I have some problem with code below which i search from google, this code is writing in vb6 but i need to rewrite and edit it in Visual Studio 2017. I meet some problem below

code Error 1:

Public Function getHTML(address)
Dim objXmlHttp : Set objXmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
objXmlHttp.Open "get", address
objXmlHttp.send
getHTML = objXmlHttp.responseText
End Function

It show me the message when i start run the program below

BC30807 Visual Basic AND VB.NET 'Let' and 'Set' assignment statements are no longer supported.

Severity Code Description Project File Line Suppression State
Error BC30807 'Let' and 'Set' assignment statements are no longer supported. CbRecorder C:\Users\USER\source\CbRecorder\CbRecorder\Form1.vb 47 Active

BC30800 Visual Basic AND VB.NET Method arguments must be enclosed in parentheses.

Severity Code Description Project File Line Suppression State
Error BC30800 Method arguments must be enclosed in parentheses. CbRecorder C:\Users\USER\source\CbRecorder\CbRecorder\Form1.vb 48 Active

Code Error 2:

Private ReadOnly Property Left(modelHtml As Object, v As Integer) As Object
Get
Throw New NotImplementedException()
End Get
End Property

It show me the message when i start run the program below

BC40003 Visual Basic AND VB.NET property 'Left' shadows an overloadable member declared in the base class 'Control'. If you want to overload the base method, this method must be declared 'Overloads'.

Code Error 3:

Private ReadOnly Property Right(modelHtml As Object, v As Integer) As Object
Get
Throw New NotImplementedException()
End Get
End Property

It show me the message when i start run the program below

BC40003 Visual Basic AND VB.NET property 'Right' shadows an overloadable member declared in the base class 'Control'. If you want to overload the base method, this method must be declared 'Overloads'.

Code Error 4:

Public Function getHTML(address)
Dim objXmlHttp : Set objXmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
objXmlHttp.Open "get", address
objXmlHttp.send
getHTML = objXmlHttp.responseText
End Function

It show me the message when i start run the program below

BC42104 Visual Basic AND VB.NET Variable is used before it has been assigned a value. A null reference exception could result at runtime.

Please help me if you know how to edit this code into vb.net. thanks in advance

Developer technologies VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.5K Reputation points
    2021-04-29T12:53:09.78+00:00

    Try something like this:

    Public Function getHTML(address) as String
       Dim objXmlHttp : objXmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
       objXmlHttp.Open("get", address)
       objXmlHttp.send
       Return objXmlHttp.responseText
    End Function
    . . .
    Private Shadows ReadOnly Property Left(modelHtml As Object, v As Integer) As Object
    . . .
    Private Shadows ReadOnly Property Right(modelHtml As Object, v As Integer) As Object
    . . .
    

    Show the new errors.

    I think that getHTML can be reimplemented using modern classes, such as WebClient.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.