Click here to Skip to main content
15,909,466 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: DLL Version Information Pin
progload27-Jul-05 12:18
progload27-Jul-05 12:18 
GeneralRe: DLL Version Information Pin
Nagendra Kamath K27-Jul-05 22:15
Nagendra Kamath K27-Jul-05 22:15 
GeneralXML File Creation Pin
Mythri.B.L27-Jul-05 1:25
Mythri.B.L27-Jul-05 1:25 
GeneralRe: XML File Creation Pin
Briga27-Jul-05 3:39
Briga27-Jul-05 3:39 
GeneralXML file creation Pin
Anonymous27-Jul-05 1:23
Anonymous27-Jul-05 1:23 
GeneralUploading a File Pin
Raj_deepak26-Jul-05 23:29
Raj_deepak26-Jul-05 23:29 
GeneralRe: Uploading a File Pin
Dave Kreskowiak27-Jul-05 6:55
mveDave Kreskowiak27-Jul-05 6:55 
GeneralResolving hostname through a proxy server Pin
Fu Manchu26-Jul-05 23:27
Fu Manchu26-Jul-05 23:27 
Hi,

I wonder if someone has the knowledge I lack, I am trying to resolve a hostname through a proxy server in vb.net but I am figure out how to combine these subroutines?

This sub is to give a proxy server some credentials and download the html from the page

Warning **** imports system.net at top of code ****

Private Sub Myproxy()
Dim result As String = ""
Try
Dim proxy As WebProxy = New WebProxy("http://proxy:80/", True)
proxy.Credentials = New NetworkCredential("username", "password", "domain.com")
Dim request As WebRequest = WebRequest.Create("http://www.c-sharpcorner.com")
request.Proxy = proxy

Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)
Dim stream As System.IO.Stream = response.GetResponseStream
Dim ec As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim reader As System.IO.StreamReader = New System.IO.StreamReader(stream, ec)
Dim chars(256) As Char
Dim count As Integer = reader.Read(chars, 0, 256)
While count > 0
Dim str As String = New String(chars, 0, 256)
result = result + str
count = reader.Read(chars, 0, 256)
End While
RichTextBox1.Text = result
response.Close()
stream.Close()
reader.Close()
Catch exp As Exception
Dim str As String = exp.Message
End Try
End Sub

This is the sub to resolve the hostname

Public Sub DisplayHostAddress(ByVal hostString As [String])
Try

Dim hostInfo As IPHostEntry = Dns.Resolve(hostString)
' Get the IP address list that resolves to the host names contained in the Alias
' property.
Dim address As IPAddress() = hostInfo.AddressList
' Get the alias names of the addresses in the IP address list.
Dim [alias] As [String]() = hostInfo.Aliases

MsgBox(("Host name : " + hostInfo.HostName))
'MsgBox(ControlChars.Cr + "Aliases : ")
Dim index As Integer
For index = 0 To [alias].Length - 1
MsgBox([alias](index))
Next index
'MsgBox(ControlChars.Cr + "IP Address list :")

For index = 0 To address.Length - 1
MsgBox(Convert.ToString(address(index)))
Next index
Catch e As Net.Sockets.SocketException
MsgBox("SocketException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As ArgumentNullException
MsgBox("ArgumentNullException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As NullReferenceException
MsgBox("NullReferenceException caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
Catch e As Exception
MsgBox("Exception caught!!!")
MsgBox(("Source : " + e.Source))
MsgBox(("Message : " + e.Message))
End Try
End Sub

so for example to resolve:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.DisplayHostAddress("http://www.codeproject.com")
End Sub

thanks
GeneralSleep in VBScript Pin
Spaz8026-Jul-05 22:27
Spaz8026-Jul-05 22:27 
GeneralRe: Sleep in VBScript Pin
Dave Kreskowiak27-Jul-05 6:53
mveDave Kreskowiak27-Jul-05 6:53 
Generalunicode conversion Pin
justzain26-Jul-05 22:09
justzain26-Jul-05 22:09 
Generalvb6 call out side *.lib Pin
justzain26-Jul-05 21:49
justzain26-Jul-05 21:49 
GeneralRe: vb6 call out side *.lib Pin
Dave Kreskowiak27-Jul-05 6:50
mveDave Kreskowiak27-Jul-05 6:50 
GeneralVBScript : launch an exe and display the output Pin
Jerome Conus26-Jul-05 21:34
Jerome Conus26-Jul-05 21:34 
QuestionWhy could not use DataTable? Pin
rushing26-Jul-05 20:44
rushing26-Jul-05 20:44 
AnswerRe: Why could not use DataTable? Pin
progload27-Jul-05 4:05
progload27-Jul-05 4:05 
QuestionHow to set the printpreviewdialog to fullscreen? Pin
rushing26-Jul-05 17:01
rushing26-Jul-05 17:01 
AnswerRe: How to set the printpreviewdialog to fullscreen? Pin
Briga27-Jul-05 3:34
Briga27-Jul-05 3:34 
Generalcaptur datagrid double click and key press Pin
samithaslk26-Jul-05 16:34
samithaslk26-Jul-05 16:34 
GeneralSql Connection1 Pin
LordLothar26-Jul-05 16:27
LordLothar26-Jul-05 16:27 
GeneralRe: Sql Connection1 Pin
| Muhammad Waqas Butt |27-Jul-05 4:33
professional| Muhammad Waqas Butt |27-Jul-05 4:33 
GeneralRe: Sql Connection1 Pin
LordLothar27-Jul-05 17:19
LordLothar27-Jul-05 17:19 
GeneralRe: Sql Connection1 Pin
| Muhammad Waqas Butt |28-Jul-05 4:03
professional| Muhammad Waqas Butt |28-Jul-05 4:03 
GeneralSql Connection1 Pin
LordLothar26-Jul-05 16:24
LordLothar26-Jul-05 16:24 
GeneralRe: Sql Connection1 Pin
Christian Graus26-Jul-05 16:32
protectorChristian Graus26-Jul-05 16:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.