From: karim on
Hi,
I'm using vb08 and I'm trying to get the public ip address. I used this code
but for some reason it's not working:
Dim lblPIp As IPAddress
lblPIp = Dns.GetHostEntry(Dns.GetHostName).AddressList.GetValue(0)

Any ideas would be appreciated.
From: Onur Güzel on
On Jan 21, 7:31 am, karim <ka...(a)discussions.microsoft.com> wrote:
> Hi,
> I'm using vb08 and I'm trying to get the public ip address. I used this code
> but for some reason it's not working:
> Dim lblPIp As IPAddress
>         lblPIp = Dns.GetHostEntry(Dns.GetHostName).AddressList.GetValue(0)
>
> Any ideas would be appreciated.

Hi,

That can be retrieved using a a 3rd-party IP detection web server
cınbined with WebClient object:

Using client As New System.Net.WebClient
' Get it in MsgBox
MsgBox(client.DownloadString _
("http://www.whatismyip.com/automation/n09230945.asp"))
End Using

Onur Güzel


From: Armin Zingler on
karim schrieb:
> Hi,
> I'm using vb08 and I'm trying to get the public ip address. I used this code
> but for some reason it's not working:
> Dim lblPIp As IPAddress
> lblPIp = Dns.GetHostEntry(Dns.GetHostName).AddressList.GetValue(0)
>
> Any ideas would be appreciated.

Not exactly the same question, but...:
http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/398ad127e5be920d

Don't know which of the IPs you consider "public".

--
Armin

From: karim on

Thank you Onur Güzel, works great. But would I be able to view the ip
address in a label/text box instead of a message?



From: karim on
Never mind, I did this and it worked... Thank you very much

lblPIp.Text =
(client.DownloadString("http://www.whatismyip.com/automation/n09230945.asp")