Visa ett inlägg
Oläst 2006-11-19, 17:32 #2
Svartrock Svartrock är inte uppkopplad
Nykomling
 
Reg.datum: Feb 2004
Inlägg: 39
Svartrock Svartrock är inte uppkopplad
Nykomling
 
Reg.datum: Feb 2004
Inlägg: 39
Function CStrIP(ByVal anNewIP)
Dim lsResults ' Results to be returned
Dim lnTemp ' Temporary value being parsed
Dim lnIndex ' Position of number being parsed
anNewIP = anNewIP + 2147483648
' Parse highest numbers first

For lnIndex = 3 To 0 Step -1
' Parse the current value for this position
lnTemp = Int(anNewIP / (256 ^ lnIndex))

' Append the number to the final results delimited by a dot
lsResults = lsResults & lnTemp & "."

' Remove the number that we just parsed
anNewIP = anNewIP - (lnTemp * (256 ^ lnIndex))
Next

' Cut off last dot
lsResults = Left(lsResults, Len(lsResults) - 1)

' Return the results
CStrIP = lsResults

End Function

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
lnResults = lnResults - 2147483648
'Return the results
CLngIP = lnResults
End Function
Svartrock är inte uppkopplad   Svara med citatSvara med citat