/ Published in: VB.NET
Use the code below to convert the IP address of your web visitors and lookup for their geographical location, e.g. country, state, city, latitude/longitude, ZIPs, timezone and so on. Free database can be downloaded at http://lite.ip2location.com.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
''' <summary> ''' Convert IPV6 Address to IP Number ''' Free geolocation database can be downloaded at: ''' http://lite.ip2location.com/ ''' </summary> Dim strIP As String = "2404:6800:4001:805::1006" Dim address As System.Net.IPAddress Dim ipnum As System.Numerics.BigInteger If System.Net.IPAddress.TryParse(strIP, address) Then Dim addrBytes() As Byte = address.GetAddressBytes() If System.BitConverter.IsLittleEndian Then Dim byteList As New System.Collections.Generic.List(Of Byte)(addrBytes) byteList.Reverse() addrBytes = byteList.ToArray() End If If addrBytes.Length > 8 Then 'IPv6 ipnum = System.BitConverter.ToUInt64(addrBytes, 8) ipnum <<= 64 ipnum += System.BitConverter.ToUInt64(addrBytes, 0) Else 'IPv4 ipnum = System.BitConverter.ToUInt32(addrBytes, 0) End If End If
URL: http://lite.ip2location.com/