Domain IP resolution in vb.net

Hi all, sometimes it could be useful to resolve a domain IP address so i wrote this simple function.

Public
function GetIP(ByVal domain as String) as String

Try
Dim Ips As New Collection
Dim i As Integer
Dim ipEntry As Net.IPHostEntry = System.Net.Dns.GetHostEntry(domain)
Dim ipAddr() As Net.IPAddress = ipEntry.AddressList
For i = 0 To ipAddr.GetUpperBound(0)
Ips.Add(ipAddr(i).ToString)
Next
Dim AddressIP As String
return Ips(1).ToString()
Catch ex As Exception
return “Can’t resolve the IP address”
End Try
end function



Leave a Reply