Inputs: asNewIP - String IP address ("192.168.0.1") to convert to a number.
Returns: Returns a Long Integer representing the IP address (3232235521)
Assumes: This function assumes that your IP address has 4 integers delimited by decimals and that the numbers range from 0 to 255.
Function CLngIP(ByVal asNewIP) Dim lnResults Dim lnIndex Dim lnIpAry ' Split the IP address using the dot as a delimiter lnIpAry = Split(asNewIP, ".", 4) ' Loop through Each number In the IP address For lnIndex = 0 To 3 ' If we are Not working With the last number... If Not lnIndex = 3 Then ' Convert the number To a value range that can be parsed from the others lnIpAry(lnIndex) = lnIpAry(lnIndex) * (256 ^ (3 - lnIndex)) End If ' Add the number To the results lnResults = lnResults + lnIpAry(lnIndex) Next ' If storing number within an Access Database, ' The variable Type "Long" ranges from -2147483648 To 2147483647 ' You will need To subtract 2147483648 from the number ' before querying the database. ' lnResults = lnResults - 2147483648 ' Return the results CLngIP = lnResults End Function