Advertisement
Guest User

Untitled

a guest
Aug 18th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Function IP2Long(IP) 'ipv4-only
  2.     Dim i, IP_l, parts
  3.  
  4.     'Validation + splitting
  5.     On Error Resume Next
  6.     parts = Split(IP, ".")
  7.     If CDbl(Replace(IP, ".", "")) = 0 Or Err Or UBound(parts) <> 3 Then Exit Function
  8.     On Error Goto 0
  9.    
  10.     'Calc
  11.     IP_l = 0
  12.     For i = 0 to 3
  13.         IP_l = IP_l + 256^(3-i)*CInt(parts(i))
  14.     Next 'i
  15.  
  16.     'Return result
  17.     IP2Long = IP_l
  18. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement