LAN IP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thank you in advance for any and all comments and help.

I have an application that an Administrator might use. I'm trying to figure
out how to programatically get the local Machine LAN IP addres. Using VB.NET
2005.
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
Net.Dns.GetHostByName(Net.Dns.GetHostName).AddressList.GetValue(0)

that will return an IPAddress object of the local computer in terms of the
LAN IPAdress of the computer
 
Thank you for a quick reply, but when I attempt to use the code you supplied
I get all kinds of errors saying sytax is obsolete and use xxxxx etc
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
eSolTec said:
Thank you for a quick reply, but when I attempt to use the code you
supplied
I get all kinds of errors saying sytax is obsolete and use xxxxx etc
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.

Use GetHostEntry:

Net.Dns.GetHostEntry(Net.Dns.GetHostName).AddressList.GetValue(0).ToString

Cheers,
Greg
 
for VB 2005 its

Net.DNS.GetHostEntry(Net.Dns.GetHostName()).AddressList.GetValue(0)

that should work
 
iwdu15,

I was able to find a post by your and get the code. in .NET 2005, some API's
have changed and the code you gave me did not work, but I did get if figured
out. Thank you for the heads up. Now I'm trying to find a way to get the
router IP address programatically. :)

Dim HostIP As IPAddress
HostIP = Dns.GetHostEntry(Dns.GetHostName).AddressList.GetValue(0)
Label1.Text = HostIP.ToString

the change was subtle but notice the GetHostEntry!
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
By you, not your. I'm really tired :) Thank you again.
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
hello Michael,

Are you using VB 2005 when testing the code? Also, what's the detailed
syntax error and which method is the compiler recommending you to use?

Here are the two code fragment that works correct in my VB 2005 console
application:

===============
For Each ip As System.Net.IPAddress In
System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())

Console.WriteLine( ip.ToString())
Next



For Each ip As System.Net.IPAddress In
System.Net.Dns.GetHostEntry(Net.Dns.GetHostName()).AddressList
Console.WriteLine(ip.ToString())
Next
=======================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
 
Steven,

Thank you for your reply. I was able to find the answer in a previous post
to correct the API change in .NET 2.0.
--
Michael Bragg, President
eSolTec, Inc.
a 501(C)(3) organization
MS Authorized MAR
looking for used laptops for developmentally disabled.
 
Back
Top