Detect Local IP Address in Visual Basic 2005 Express Edition (Beta 2)

I'm trying to write a simple program in my newly downloaded copy of Visual Basic 2005 Express Edition (Beta 2).

I want to display the IP address of the local machine (i.e. the machine the program is being run on).

I would previously have used something like this:

Imports System.Net
Imports System.Net.Sockets

Dim IPAddressAsNew IPAddress(Dns.GetHostByName (Dns.GetHostName).AddressList(0).Address)
Dim strIPAddressAsString
= IPAddress.ToString

However, this now displays a warning that this format has now been depracted and to useIPAddress.Equals method instead.

Could anyone shed any light on how to get my local IP address in VB 2005 Express (Beta 2)?

Many thanks.

[1403 byte] By [ollertoncj] at [2008-2-4]
# 1
This should work:


Dim IPAddress As IPAddress = Dns.GetHostEntry(Dns.GetHostName).AddressList(0)
Dim
strIPAddress As String = IPAddress.ToString


TobinTitus at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2

I have wondered the same thing, but not only do i want to get the IPAddress, but the subnet address as well.

I was wondering why you cant say something like this

Dim IPAddress As IPAddress = My.Computer.Network.IPAddress

One thing i already know is that there is no IPAddress in the namespace of My.Computer.Network

I was wondering why not.

wramos at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic Language...