Getting IP Address

  • Thread starter Thread starter Philip Grace
  • Start date Start date
P

Philip Grace

Hi,

I have been working on the function below, to get the current ip address in
use. I am using a Symbol MC70 device.

When it is connected to ActivSync though the cradle, it returns 3 addresses
(the 2nd of which is the WiFi IP address). However, when not conencted to
the cradle, it doesn't return any at all.

What I'm trying to get is the IP address of the WiFi connection.

Can anyone help?

Cheers,
Philip.


Public Function GetIPAddress() As String
Dim sIP As String
Dim myHost As System.Net.IPHostEntry
Dim i As Integer
myHost = Dns.GetHostEntry("")

For i = 1 To UBound(myHost.AddressList) - 1
sIP = myHost.AddressList(i).ToString
MsgBox("IP : " + sIP)
Next
sIP = myHost.AddressList(0).ToString
GetIPAddress = sIP
End Function
 
Hi,

I have been working on the function below, to get the current ip address in
use. I am using a Symbol MC70 device.

When it is connected to ActivSync though the cradle, it returns 3 addresses
(the 2nd of which is the WiFi IP address). However, when not conencted to
the cradle, it doesn't return any at all.

What I'm trying to get is the IP address of the WiFi connection.

Can anyone help?

Cheers,
Philip.

Public Function GetIPAddress() As String
Dim sIP As String
Dim myHost As System.Net.IPHostEntry
Dim i As Integer
myHost = Dns.GetHostEntry("")

For i = 1 To UBound(myHost.AddressList) - 1
sIP = myHost.AddressList(i).ToString
MsgBox("IP : " + sIP)
Next
sIP = myHost.AddressList(0).ToString
GetIPAddress = sIP
End Function

Try something like...

Dim hostName As String = Dns.GetHostName()
Dim currenthost As IPHostEntry = Dns.GetHostEntry(hostName)

Then check the array "currenthost.AddressList(n)" where n is the
array number.
 
Thanks, that did the trick.

Philip.

George Leithead said:
Try something like...

Dim hostName As String = Dns.GetHostName()
Dim currenthost As IPHostEntry = Dns.GetHostEntry(hostName)

Then check the array "currenthost.AddressList(n)" where n is the
array number.
 
Back
Top