Convert Hostname to Ip Address in vb.net


  • ListBox1.Items.Clear()
    Try
    ' Host Name resolution to IP
    Dim host As IPHostEntry = Dns.GetHostEntry(TextBox1.Text.Trim())
    Dim ipaddr As IPAddress() = host.AddressList


    ' Loop through the IP Address array and add the IP address to Listbox
    For Each addr As IPAddress In ipaddr
    ListBox1.Items.Add(addr.ToString())


    Next addr
    ' Catch unknown host names
    Catch ex As System.Exception
    MessageBox.Show(ex.Message)


    End Try

    End Sub

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week