View Single Post
  #4 (permalink)  
Old March 24th, 2002
Joetella Joetella is offline
Disciple
 
Join Date: January 3rd, 2002
Location: USA,Connecticut
Posts: 12
Joetella is flying high
Default

Here are my routines for IP conversion,
Note that I'm using Byte arrays and not Strings:

Code:
Private Function IPtoByte(ByVal sTemp As String) As Byte()

   On Error GoTo HandleError
   
   Dim lPos As Long
   Dim sBucket() As String
   Dim bTemp() As Byte
   ReDim bTemp(0 To 3)
   
   sBucket = Split(sTemp, ".")
   For lPos = 0 To 3
      bTemp(lPos) = CByte(Val(sBucket(lPos)))
   Next lPos
   IPtoByte = bTemp
   Exit Function
    
HandleError:
   Call LogError("IPtoByte")
   
End Function

Private Function ByteToIP(ByRef bTemp() As Byte, ByVal lTemp As Long) As String

   On Error GoTo HandleError
   
   ByteToIP = CStr(bTemp(lTemp)) _
      & "." & CStr(bTemp(lTemp + 1)) _
      & "." & CStr(bTemp(lTemp + 2)) _
      & "." & CStr(bTemp(lTemp + 3))
   Exit Function
    
HandleError:
   Call LogError("ByteToIP")
   
End Function
Reply With Quote