+92 332 4229 857 99ProjectIdeas@Gmail.com

Finding IP Address Of HostName (Vb.net)



The following code shows you how to get the ip addresses of the mentioned host name. For this you have to add namespace Imports System.Net to use this. see the code below. Following example showing the ipAddress list of google. You can write your desired name in hostName to get its ip address list.







Imports System.Net

Try
     
    Dim hostName = "www.google.com"
    Dim hostEntry As IPHostEntry = Dns.GetHostEntry(hostName)
    Dim ipAddress As IPAddress() = hostEntry.AddressList

    For i = 0 To ipAddress.Length - 1
        Console.WriteLine(ipAddress.GetValue(i).ToString())
    Next

Catch ex As Exception

      MsgBox(ex.Message, MsgBoxStyle.Critical)

End Try


0 comments: