Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
Function PBMain() As Long
Local ips As String, ip As Dword
ips = "192.168.1.66"
ip = IPFromString(ips)
? "This IP string: " + ips + $CrLf + "is this value: " + Str$(ip) + $CrLf + "which is this IP string: " + DottedIP(ip)
End Function
Function IPFromString(ips As String) As Dword
Local ip As Dword
ip = Val(Parse$(ips,".",4)) * 256^3 'or 2^24
ip += Val(Parse$(ips,".",3)) * 256^2 'or 2^16
ip += Val(Parse$(ips,".",2)) * 256^1 'or 2^8
ip += Val(Parse$(ips,".",1))
Function = ip
End Function
Function DottedIP (ByVal ip As Dword) As WString
Local x As Byte Ptr
x = VarPtr(ip)
Function = Using$("#_.#_.#_.#", @x, @x[1], @x[2], @x[3])
End Function
'gbs_01429
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm