Finds IP Address of computer named "www.codeproject.com".
Dim strHostName As String = "www.codeproject.com"
Dim strIPAddress As String = ""
Dim objAddressList() As System.Net.IPAddress = _
System.Net.Dns.GetHostEntry(strHostName).AddressList
For x = 0 To objAddressList.GetUpperBound(0)
If objAddressList(x).AddressFamily = Net.Sockets.AddressFamily.InterNetwork Then
strIPAddress = objAddressList(x).ToString
Exit For
End If
Next
Notes:
This code was tested on Visual Basic 2012 .NET Framework 4.0.
In earlier versions of the .NET Framework, there is a class named Dns.GetHostName but that has been deprecated and removed from the .NET Framework. Dns.GetHostEntry is the replacement.