Hi guys,
I need your help. I want to connect to the proxy server using with the webbrowser while reads the strings of the proxy username, password, ip and the ports in each textbox.
Here it is the code:
Code:Imports System.Net Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form Public Function GetHTMLPage(ByVal URL As String, Optional ByVal UseProxy As Boolean = False, Optional ByVal ProxyAddress As String = "", Optional ByVal ProxyPort As Integer = 0, Optional ByVal UserName As String = "", Optional ByVal PassWord As String = "", Optional ByVal Domain As String = "") As String Dim sResult As String = "" Try Dim objResponse As WebResponse Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(URL) If Not UseProxy Then Dim oProxy As New WebProxy(ProxyAddress, ProxyPort) If Domain <> "" Then oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain) Else oProxy.Credentials = New NetworkCredential(UserName, PassWord) End If objRequest.Proxy = oProxy End If objRequest.Method = "GET" objRequest.Timeout = 120000 ' 20 sec. objResponse = objRequest.GetResponse Dim sr As System.IO.StreamReader = New System.IO.StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7) sResult = sr.ReadToEnd() sr.Close() ' when code-execution has reached this point without ' throwing an error, the html page is loaded which ' means all is o.k. MessageBox.Show("You are connected Success") Catch ex As System.Exception MessageBox.Show("You have failed connected") End Try Return sResult End Function Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If GetHTMLPage("http://www.whatismyip.com" & ProxyAddress.Text & IIf(IsNumeric(ProxyPorts.Text), ProxyPorts.Text, 0), ProxyUsername.Text, ProxyPassword.Text) Is "" Then WebBrowser1.Url = New Uri("http://www.whatismyip.com") End If End Sub
However, I have received the error that are jumping on If GetHTMLPage statement. The error is Conversion from string "name of string" to type 'Boolean' is not valid.
I don't know what to do.
Any idea?![]()




Reply With Quote