Programming Tutorials

How to find IP Address of Host using .net code

By: Issac in VB.net Tutorials on 2009-02-21  

Here is a simple code for you to find the IP address of a host machine System.net namespace provides the information about IP Address.

If you pass localhost in GetHostByName return the IP Address of local machine.

Imports System.Net
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
        Dim ip As IPAddress() = hostname.AddressList
        TextBox2.Text = ip(0).ToString()
    End Sub
End Class

This source code returns the ip address of the host you are working with.





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)