Home All Groups Group Topic Archive Search About
Author
8 Sep 2006 1:11 AM
eSolTec, Inc. 501(c)(3)
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.

Author
8 Sep 2006 1:24 AM
iwdu15
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

--
-iwdu15
Author
8 Sep 2006 1:32 AM
eSolTec, Inc. 501(c)(3)
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.


Show quoteHide quote
"iwdu15" wrote:

> 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
>
> --
> -iwdu15
Author
8 Sep 2006 2:30 AM
Greg
Show quote Hide quote
"eSolTec, Inc. 501(c)(3)" <esoltec@noemail.nospam> wrote in message
news:89C3AC5E-4223-494F-9753-8C39C1DD4D6C@microsoft.com...
> 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.
>
>
> "iwdu15" wrote:
>
>> 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

Use GetHostEntry:

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

Cheers,
Greg
Author
8 Sep 2006 2:31 AM
iwdu15
for VB 2005 its

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

that should work
--
-iwdu15
Author
8 Sep 2006 2:35 AM
eSolTec, Inc. 501(c)(3)
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.


Show quoteHide quote
"iwdu15" wrote:

> for VB 2005 its
>
> Net.DNS.GetHostEntry(Net.Dns.GetHostName()).AddressList.GetValue(0)
>
> that should work
> --
> -iwdu15
Author
8 Sep 2006 2:38 AM
eSolTec, Inc. 501(c)(3)
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.
Author
8 Sep 2006 2:41 AM
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.
Author
8 Sep 2006 2:46 AM
eSolTec, Inc. 501(c)(3)
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.


Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

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