LAN IP

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.
 
G

Guest

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
 
G

Guest

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.
 
G

Greg

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
 
G

Guest

for VB 2005 its

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

that should work
 
G

Guest

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.
 
G

Guest

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.
 
S

Steven Cheng[MSFT]

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SPAM 1
Test Post 2
Check for .NET Installed 11
bypass security in Outlook 3
Check for .NET Framework 2
Pause and Stop Search 2
validate email address in input textbox 1
Fill in textboxes programatically in ASPX 3

Top