Convert StringIP to NumericIP
Converts a string ip address ("192.168.0.1") to a Long number (3232235521). One of the resons to do this would be to store IP addresses in databases. Numbers greatly reduce the size required to store this information.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
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
Original Comments (3)
Recovered from Wayback Machine