I want You to ask for a help. how to adapt this VB.NET code to Visual Basic 6 ?

Imports System.Collections.Generic
Imports System.IO
Imports System.Net

Namespace blogtest
Class Program
Private Shared Sub Main(args As String())
Dim http As New simplehttp()
‘testing on ipcheckit.com so we can make sure we’re really connecting through proxy. Look for proxy IP in html printed in console
‘remember to change 127.0.0.1, 8080, login, password to your working proxy details
Dim html As String = http.geturl(”http://ipcheckit.com/”, “127.0.0.1″, 8080, “login”, “password”)
System.Console.WriteLine(html)
End Sub
End Class

Class simplehttp
Public Function geturl(url As String, proxyip As String, port As Integer, proxylogin As String, proxypassword As String) As String
Dim resp As HttpWebResponse
Dim req As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
req.UserAgent = “Mozilla/5.0″
req.AllowAutoRedirect = True
req.ReadWriteTimeout = 5000
req.CookieContainer = New CookieContainer()
req.Referer = “”
req.Headers.[Set](”Accept-Language”, “en,en-us”)
Dim stream_in As StreamReader

Dim proxy As New WebProxy(proxyip, port)
‘if proxylogin is an empty string then don’t use proxy credentials (open proxy)
If proxylogin “” Then
proxy.Credentials = New NetworkCredential(proxylogin, proxypassword)
End If
req.Proxy = proxy

Dim response As String = “”
Try
resp = DirectCast(req.GetResponse(), HttpWebResponse)
stream_in = New StreamReader(resp.GetResponseStream())
response = stream_in.ReadToEnd()
stream_in.Close()
Catch ex As Exception
End Try
Return response
End Function

Public Function getposturl(url As String, postdata As String, proxyip As String, port As Short, proxylogin As String, proxypassword As String) As String
Dim resp As HttpWebResponse
Dim req As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
req.UserAgent = “Mozilla/5.0″
req.AllowAutoRedirect = True
req.ReadWriteTimeout = 5000
req.CookieContainer = New CookieContainer()
req.Method = “POST”
req.ContentType = “application/x-www-form-urlencoded”
req.ContentLength = postdata.Length
req.Referer = “”

Dim proxy As New WebProxy(proxyip, port)
‘if proxylogin is an empty string then don’t use proxy credentials (open proxy)
If proxylogin “” Then
proxy.Credentials = New NetworkCredential(proxylogin, proxypassword)
End If
req.Proxy = proxy

Dim stream_out As New StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)
stream_out.Write(postdata)
stream_out.Close()
Dim response As String = “”

Try
resp = DirectCast(req.GetResponse(), HttpWebResponse)
Dim resStream As Stream = resp.GetResponseStream()
Dim stream_in As New StreamReader(req.GetResponse().GetResponseStream())
response = stream_in.ReadToEnd()
stream_in.Close()
Catch ex As Exception
End Try
Return response
End Function
End Class
End Namespace

Help anyone?

Why do you want to regress to VB6?

There is no console program in VB6: System.Console.WriteLine You're using namespaces. Using namespaces are a superior feature of the VB.Net language.

You can use class modules in VB6 for classes. But the .NET platform was developed mainly because of the internet revolution, besides upgrading and fixing a multitude of problems with VB6. You would be better off staying with VB.Net. Most of the internet routines are far superior to what you'll find in VB6. Retrogressing code from VB.Net to VB6 is mostly an exercise in futility.

Besides, I like to keep my hair. Pulling out my hair while trying to make internet routines work in VB6 is not conducive to the health of my scalp.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.