في قسم الاستيرادات في بداية الملف
Imports System.Net Imports System.Net.Sockets
ضع على الفورم صندوق نصوص و زرا و صندوق قائمة وأدخل الكود التالي في الزر
ListBox1.Items.Clear()
Dim hostName As String = TextBox1.Text
Try
' Call the GetHostByName method, passing a DNS style host name(for example,
' "www.contoso.com") as an argument to obtain an IPHostEntry instance, that
' contains information for the specified host.
Dim hostInfo As IPHostEntry = Dns.GetHostByName(hostName)
' 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 the addresses in the IP address list.
Dim [alias] As [String]() = hostInfo.Aliases
ListBox1.Items.Add(("Host name : " + hostInfo.HostName))
ListBox1.Items.Add(ControlChars.Cr + "Aliases : ")
Dim index As Integer
For index = 0 To [alias].Length - 1
ListBox1.Items.Add([alias](index))
Next index
ListBox1.Items.Add(ControlChars.Cr + "IP address list : ")
For index = 0 To address.Length - 1
ListBox1.Items.Add(address(index))
Next index
Catch ec As SocketException
ListBox1.Items.Add("SocketException caught!!!")
ListBox1.Items.Add(("Source : " + ec.Source))
ListBox1.Items.Add(("Message : " + ec.Message))
ec = Nothing
Catch ea As ArgumentNullException
ListBox1.Items.Add("ArgumentNullException caught!!!")
ListBox1.Items.Add(("Source : " + ea.Source))
ListBox1.Items.Add(("Message : " + ea.Message))
ea = Nothing
Catch eb As Exception
ListBox1.Items.Add("Exception caught!!!")
ListBox1.Items.Add(("Source : " + eb.Source))
ListBox1.Items.Add(("Message : " + eb.Message))
eb = Nothing
End Tryومرفق أيضا المثال جاهز

