How To Get IP Address From Host Name In VB.NET

This tutorial is about coding a Host To IP Address Program , how this works ? this finds the ip address of the host or i can say it converts the domain name to ip address so lets begin making this

1.open your visual basic 2008/2010

2.create a new project and name it whatever you like to

3.add a button and change its text property to get ip

4.add two textboxes

textbox1 is for host

textbox2 is for ip address

5.add two labels and change their text properties as below

label1 - host : 
label2 - IP Address :

6.now set the textboxes near the labels as below


7.time to code double click your form and erase everything and add the codes

Imports System.Net
Public Class Form1

    'Author : Mohamed Shimran
    'Blog : http://www.ultimateprogrammingtutorials.blogspot.com

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            MsgBox("Enter The Host")

        Else
            Dim hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
            Dim ip As IPAddress() = hostname.AddressList
            TextBox2.Text = ip(0).ToString()
        End If
    End Sub

End Class

8.now debug and see the work


3 comments

Thanks for your information. I have checked my host to ip and ip to host name from this site WhoisXY.com

Reply

thank you, worked !

Reply

Post a Comment

Note: Only a member of this blog may post a comment.