' Return the IP address Public Function GetIP() As String Dim lcIP As String = "" Dim loNetworkInterface As System.Net.NetworkInformation.NetworkInterface = Nothing Dim loNetworkInterfaces As System.Net.NetworkInformation.NetworkInterface() = Nothing Dim loUnicastIPAddressInformation As System.Net.NetworkInformation.UnicastIPAddressInformation = Nothing ' Initialization loNetworkInterfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() ' For each network interface For Each loNetworkInterface In loNetworkInterfaces ' If this is our primary adapter If loNetworkInterface.NetworkInterfaceType = System.Net.NetworkInformation.NetworkInterfaceType.Wireless80211 OrElse _ loNetworkInterface.NetworkInterfaceType = System.Net.NetworkInformation.NetworkInterfaceType.Ethernet Then ' For each IP address For Each loUnicastIPAddressInformation In loNetworkInterface.GetIPProperties().UnicastAddresses ' If this the primary IP address If loUnicastIPAddressInformation.Address.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then lcIP = loUnicastIPAddressInformation.Address.ToString() End If Next End If Next Return lcIP End Function