Alejandro Acuña
2024-09-16 adba74e107bcda9e1cb510bc14364b02e781baef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Module IpParser
 
    Public Function ParseIP(ByVal IpTxt As String, ByRef IPByte3 As Byte, ByRef IPByte2 As Byte, ByRef IPByte1 As Byte, ByRef IPByte0 As Byte) As Boolean
        Dim S() As String
        Dim Exito As Boolean
        S = IpTxt.Split(".")
        If UBound(S) = 3 Then
            IPByte3 = Val(S(0))
            IPByte2 = Val(S(1))
            IPByte1 = Val(S(2))
            IPByte0 = Val(S(3))
            Exito = True
        Else
            Exito = False
        End If
        Return Exito
    End Function
 
    Public Function IpToLong(ByVal IpTxt As String) As Long
        Dim Ip1, Ip2, Ip3, Ip4 As Byte
        Dim L As Long
        ParseIP(IpTxt, Ip4, Ip3, Ip2, Ip1)
        L = (Ip1 * &H1000000) + (Ip2 * &H10000) + (Ip3 * &H100) + Ip4
        Return L
    End Function
End Module