© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
Quick Links
Easy Studies

  HomeSource Code DotNet ►VB.Net▼

Get IPAddress of machine in local area network

         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


            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, )


        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



SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑