We can Get IP Address Machines on the Local Area network from Machine Name
using System.DirectoryServices Namespace.
Public Class Form1
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
TextBox1.Text = "Localhost"
Label2.Text = "Machine Name"
Label3.Text = "IP"
Button1.Text = "Get Machine IP"
Me.Text = "Get Machine IP"
End Sub
Function
GetIPAddress(ByVal CompName As String) As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
Try
With System.Net.Dns.GetHostByName(CompName)
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
End With
GetIPAddress = sAddr
Catch Excep As Exception
MsgBox(Excep.Message, MsgBoxStyle.OkOnly, )
Finally
End Try
End Function
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Label1.Text = GetIPAddress(TextBox1.Text)
End Sub
End Class
OUTPUT
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com