VB.NET Technology

VB.Net Projects

VB.Net Project 1

How to Access IP Address of LAN Connected Computers
Previous Home Next
adplus-dvertising

In VB.Net with the help of Namespace System.Net.Sockets and System.Net we can build an application through which we can find ID address of the machine connected with LAN.

Program code is given below-

System.Net.IPHostEntry - Provides a container class for internet host address information .

Dns.Resolve("strhostname")- Resolve a DNS hostname or IP Address to an System.Net.IPHostEntry instance.

Console.ReadKey()- Obtains the next character or function key pressed by the user. The pressed key is optimally displayed in the console window.

Imports System.Net
Imports System.Net.Sockets
Module Module1
    Sub Main()
        Dim strHost As String
        Console.Write("Input host : ")
        strHost = Console.ReadLine()
        Dim IPHost As IPHostEntry = Dns.Resolve(strHost)
        Console.WriteLine(IPHost.HostName)
        Dim address As IPAddress() = IPHost.AddressList
        Console.WriteLine("List IP {0} :", IPHost.HostName)
        For i As Integer = 0 To address.Length - 1
            ' output list of IP address
            Console.WriteLine(address(i))
        Next
        Console.ReadKey()
    End Sub
End Module

IP Address of Machine-02

IP Address of Machine-01

Previous Home Next