I have tried something someone gave me but it seems to be obsolete (there is
a wavy blue line under the "myip.Address." ) and returns a number that does
not appear to be a IP address. It does not have periods "." in it.
This is what I am using now.
Thanks!
Bob
-----
Dim myip As Net.IPAddress
myip =
Net.Dns.GetHostByName(Environment.MachineName).AddressList(0)
Dim IPAddress As String
IPAddress = myip.Address.ToString
Dim IP() As String
Dim MyPC As String = Dns.GetHostName
For n As Integer = 0 To
UBound(Dns.GetHostEntry(Dns.GetHostName()).AddressList)
ReDim Preserve IP(n)
IP(n) = Dns.GetHostEntry(MyPC).AddressList(n).ToString
Next
-Jerry
"BobAchgill" <BobAc...@discussions.microsoft.com> wrote in message
news:08B42E2E-F0FB-4BC9...@microsoft.com...
As a computer can have multiple network interfaces and multiple IP
addresses, it is not that simple. First, call
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
Then, for each returned interface, call the GetIPProperties function which
returns an IPInterfaceProperties object. Among others, this object has a
UnicastAddresses property returning a UnicastIPAddressInformationCollection
object. It's a collection of UnicastIPAddressInformation objects. They have
an Address property. You can call it's ToString function.
...but why so many words? Some code:
Dim NInterfaces As NetworkInterface()
NInterfaces = NetworkInterface.GetAllNetworkInterfaces
For Each NInterface As NetworkInterface In NInterfaces
Debug.Print("Interface: " & NInterface.Description)
For Each Info As IPAddressInformation _
In NInterface.GetIPProperties().UnicastAddresses
Debug.Print(" " & Info.Address.ToString())
Next
Next
Armin
Dim NIC_IPs() As IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList
For Each IPAdr As IPAddress In NIC_IPs
Debug.Print(IPAdr.ToString)
Next
(Remember to use 'Imports System.Net')
ShaneO
There are 10 kinds of people - Those who understand Binary and those who
don't.
Dim ipAddressInfo As System.Net.IPHostEntry =
System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName())
Dim ipAddress As String = ipAddressInfo.AddressList.GetValue(0).ToString
Works for me.