Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get ip address of this pc with windows app

172 views
Skip to first unread message

cj

unread,
Mar 15, 2007, 2:07:01 PM3/15/07
to
How can a windows app get the ip address of the machine it is running
on? vb 2005

Newbie Coder

unread,
Mar 15, 2007, 2:50:07 PM3/15/07
to
CJ,

This is how to get the internal IP address:

Imports System.Net

Dim ipAddress As IPHostEntry = Dns.GetHostByName(Dns.GetHostName)
Me.Text = ipAddress.AddressList.GetValue(0).ToString

I hope this helps,

--
Newbie Coder
(It's just a name)


cj

unread,
Mar 16, 2007, 10:21:36 AM3/16/07
to
had to change it a bit but it works

Dim ipAddressInfo As IPHostEntry = Dns.GetHostEntry(Dns.GetHostName())
Dim ipAddress As String = ipAddressInfo.AddressList.GetValue(0).ToString

Walter Wang [MSFT]

unread,
Mar 19, 2007, 9:55:35 PM3/19/07
to
Hi CJ,

You're right that Dns.GetHostByName is obsolete in .NET 2.0,
Dns.GetHostEntry should be used instead.

Regards,
Walter Wang (waw...@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

0 new messages