Click here to Skip to main content
16,017,249 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 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 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 Erroe 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 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

What I have tried:

i wish someone will know how to do it.
Posted
Updated 17-Feb-23 17:05pm
Comments
Richard MacCutchan 29-Apr-21 8:24am    
Sorry, we do not offer a conversion service.
Mr.Kim2050 29-Apr-21 9:00am    
the problem is this vb6 code is not my own code build up, is someone post in google, and i try to rewrite this code again. i really hope someone will know how to do it

Don't try to convert it would be my advice. Just write the VB.NET code that does the same thing.

For starters don't try to use MSXML2.XMLHTTP.6.0. Use the built-in functionality with System.Xml (e.g. see xml - MSXML in VB.NET[^] ). That should get you past the first two errors you list

Similarly the "Code Error 2" and "Code Error 3" will probably just "go away" if you use HtmlDocument Class (System.Windows.Forms) | Microsoft Docs[^]

Code "Error" 4 fully explains the problem but will also go away when you use .NET constructs
 
Share this answer
 
Comments
Mr.Kim2050 29-Apr-21 8:59am    
the problem is this vb6 code is not my own code build up, is someone post in google, and i try to rewrite this code again. i really hope someone will know how to do it
CHill60 29-Apr-21 9:04am    
I've just told you how to do it - use the code you have copied and rewrite it, from scratch, in VB.NET. If you attempt to "convert" it you will not only get the errors you are already seeing, but you might find strange results at run-time from using VERY out of date components.
E.g. the first bit of code you have should be using HttpWebRequest.GetResponse Method (System.Net) | Microsoft Docs[^]
Dave Kreskowiak 29-Apr-21 10:21am    
It does not matter. Trying to use VB6 code in VB.NET is not going to do you any good. You have to understand what the VB6 code is doing and rewrite it from scratch to do the same thing.

Trying to do a line-for-line conversion of the code isn't going to work.
OriginalGriff 29-Apr-21 10:02am    
+5!
Quote:
the problem is this vb6 code is not my own code build up, is someone post in google, and i try to rewrite this code again. i really hope someone will know how to do it

Chill60 is right: it's not worth the effort of reworking VB6 code like that into a "modern language", no matter how much VB6 looks like VB.NET.

The underlying frameworks are far, far too different to make any sense of a conversion - you are far, far better off rewriting the code to do the same job using the original as a "specification". What you will end up with will be code that can be maintained as well as code that others won't look at and go "WTE? Why did you do it that way?"

Blindly finding code on Google and expecting it to be exactly what you want is a mistake ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900