Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to Get Host Name and IP Address in VB.Net

Author: DevASP
Download Source Code : 341_Get Host Name & IP.zip

This article is about how you can get the host name and its IP address. In some situations you want to get the IP address of your windows application user.

  • Steps you will do. 
  • Start visual studio and create a new window application. 
  • Set the following properties of form.
Text = “Host Name & IP”

 

  • Drop a button control on your form and set its following form.

Text = “Get Host Name & IP Address”

Name = “btget”

 

  • Drop a label control on your form and set its following properties.

Text = “It’s easy to get the host name and IP address”

 

  • Open your code window and import following namespace in your code.

Dim myHost As String = System.Net.Dns.GetHostName

Dim myIPs As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(myHost)

MessageBox.Show("The name of the host is = " & myIPs.HostName, "Host Name", MessageBoxButtons.OK, MessageBoxIcon.Information)

For Each myIP As System.Net.IPAddress In myIPs.AddressList

MessageBox.Show("The IP address of host is = " & myIP.ToString, "Host IP Address", MessageBoxButtons.OK, MessageBoxIcon.Information)

Next

 

 

 

Article Comments
I have been looking for the answer to my IP code snippet woes, and this is it!

Thank you!

Posted on 7/13/2007 8:43:09 PM by Adrian

Awesome article, I've been looking for this code snippet for hours :\

Posted on 7/13/2007 8:43:48 PM by adrian

How I get host name giving ip address

Posted on 2/25/2008 5:54:05 AM by Soumitra Samanta

Can you give me code which display ip address of all connected and currentely enabled or working pc in LAN network

Posted on 11/29/2008 4:14:35 AM by Siddhesh

I want only IP addresses of all live PC's in LAN network without using host name.

Posted on 12/1/2008 6:25:00 AM by Siddhesh

thaks this is realy help me

Cheers
Satya

Posted on 11/28/2009 1:15:08 AM by satya

great job

Posted on 12/12/2009 1:10:41 PM by baby programmer

What an idea sir Ji

Posted on 1/12/2010 5:12:40 AM by Gopu

Very useful simple.

Thank you...

Posted on 1/28/2010 4:08:06 AM by Fauzy

I need help to display a list of all IP addresses in my Network in Visual Studio 2008...

Posted on 5/3/2010 11:58:59 AM by Ebrahim Alzobiry

Cool , appreciate it ,

Posted on 7/17/2010 4:57:51 PM by Code

thank you very much,,
i've been looking for this code for a long time,,
and now,,
i've found it,,thank you,,,,
great,,
hope it will work,, :)

Posted on 8/16/2010 5:09:21 AM by owie

How to get server name from system parameters?

Posted on 8/25/2010 2:30:08 AM by Reshma

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to Set File Attributes Using Visual Basic.Net

Disclaimer - Privacy
© 2002-2017 DevASP.net