- Home
·
- Internet/HTML
·
- Converts a long integer IP address into a string IP address (opposite of AddressStringToLong functi
Converts a long integer IP address into a string IP address (opposite of AddressStringToLong functi
Converts a long integer IP address into a string IP address (opposite of AddressStringToLong function found in many Ping programs)
Rate Converts a long integer IP address into a string IP address (opposite of AddressStringToLong functi
(1(1 Vote))
Dim HexAddr As String
Dim bytes(4) As String
Dim IPNodes(4) As String
Dim x As Integer
Dim y As Integer
'This function receives a long IP address and
'converts it to a valid string IP address
'Note that the long IP address is created by taking
'Each byte of the IP address and converting to hex
'in reverse order and then converting the resulting
'4 bytes of hex to a decimal number
'Get the hex value of the long
HexAddr = Hex$(addr)
'Add a leading zero to the first hex byte if needed
If Len(HexAddr) = 7 Then
HexAddr = "0" & HexAddr
End If
'convert each hex byte value into a decimal string and
'put into the array in reverse order
y = 4
For x = 1 To 8 Step 2
bytes(y) = Mid(HexAddr, x, 2)
y = y - 1
Next x
'convert each hex byte string to a decimal address
For x = 1 To 4
IPNodes(x) = LTrim(Str(Val("&H" & bytes(x))))
Next x
'convert the strings to an IP address
LongToIP = ""
For x = 1 To 4
If x < 4 Then
LongToIP = LongToIP & IPNodes(x) & "."
Else
LongToIP = LongToIP & IPNodes(x)
End If
Next x
End Function
Converts a long integer IP address into a string IP address (opposite of AddressStringToLong functi Comments
No comments yet — be the first to post one!
Post a Comment