[VB.NET]DNS IP Lookup 07-17-2013, 10:24 PM
#1
Well, for this tutorial you should add 2 Labels, 2 TextBox Controls and 1 Button. Make your form look something like this:
![[Image: cLK6eR3.png]](http://i.imgur.com/cLK6eR3.png)
Go in to the code view, and paste this function which will retrieve the ip of the website.
Then, go back to design view and double click your button and paste the code below which will place the IP in TextBox2
If this works, you should see something like this:
![[Image: cLK6eR3.png]](http://i.imgur.com/cLK6eR3.png)
Go in to the code view, and paste this function which will retrieve the ip of the website.
Code:
Public Function GetIP(ByVal URL As String)
If url.ToString.Contains("http://") Then
url = url.Replace("http://", String.Empty)
End If
If url.ToString.Contains("/") Then
url = url.Replace("/", String.Empty)
End If
Dim hostname As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(URL)
Dim ip As System.Net.IPAddress() = hostname.AddressList
Return ip(0).ToString()
End Function
Then, go back to design view and double click your button and paste the code below which will place the IP in TextBox2
Code:
TextBox2.Text = GetIP(TextBox1.Text)
If this works, you should see something like this:
![[Image: mFiOsAd.png]](http://i.imgur.com/mFiOsAd.png)
![[Image: GiXvY27.png]](http://i.imgur.com/GiXvY27.png)