Click here to Skip to main content
15,890,438 members
Articles / Programming Languages / Visual Basic
Alternative
Tip/Trick

Whats My IP Address ?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
24 Nov 2011CPOL 7.9K   2
Dim ipE As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName) Dim AL As Array = Dns.GetHostEntry(vWrkStn).AddressList Dim A As IPAddress For Each A In AL If A.AddressFamily = Sockets.AddressFamily.InterNetwork Then ...
Dim ipE As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)


       Dim AL As Array = Dns.GetHostEntry(vWrkStn).AddressList
       Dim A As IPAddress
       For Each A In AL

           If A.AddressFamily = Sockets.AddressFamily.InterNetwork Then
               IP4 = A
               Exit For
           End If
       Next
       MyIP = IP4.ToString

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
General- I replaced 'vWrkStn' with 'Environment.MachineName' and de... Pin
dbraseth29-Nov-11 16:41
dbraseth29-Nov-11 16:41 
GeneralReason for my vote of 5 this method actually works! Pin
dbraseth29-Nov-11 16:34
dbraseth29-Nov-11 16:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.