65.9K
CodeProject is changing. Read more.
Home

Whats My IP Address ?

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Sep 22, 2011

CPOL
viewsIcon

10283

On Vista/Win 7, I have seen code where only a single period is returned for (0). This makes sure you get the actual IP regardless of the system.Const IPPattern As String = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"With Dns.GetHostEntry(System.Environment.MachineName) Return...

On Vista/Win 7, I have seen code where only a single period is returned for (0). This makes sure you get the actual IP regardless of the system.

Const IPPattern As String = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"

With Dns.GetHostEntry(System.Environment.MachineName)
    Return .AddressList.Where(Function(a) _
       Regex.IsMatch(a.ToString, IPPattern)).First.ToString
End With