Advertisement
ASP_Volume3 Coding Standards #62846

IsIP Function v2

Updated version of IsIP function. Should clear up all the problems in the last one. Here ya go, =)

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Function IsIP(strIP As String) As Boolean
 Dim splitIP() As String, i As Long
 IsIP = True 'Starts out as true
 splitIP$ = Split(strIP$, ".", -1, 1) 'Split IP To check value
 '========================================
 'Things we must check to verify IP
 '1. Make sure there are 4 sections to IP
 '2. Make sure each section of IP is not
 ' greater than 255
 '3. Make sure each section of IP does
 ' not t contain a negative
 '4. Make sure each section of IP is nume-
 ' ric
 '5. Make sure first section of IP is not
 ' 0
 '=======================================
 If UBound(splitIP$) <> 3 Then
  IsIP = False 'make sure there is only 4 nodes =)
 Else
  For i = 0 To UBound(splitIP$) 'loop through array and check 3 things
 
 
   If IsNumeric(splitIP(i)) = False Then
    IsIP = False
    Exit For
   Else
    
    If splitIP(0) = 0 Then 'first digit cannot be 0
     IsIP = False
     Exit For
    End If
 
    If splitIP(i) > 255 Or splitIP(i) < 0 Then
     IsIP = False
     Exit For
    End If
   End If
  Next i
 End If
 
End Function
Original Comments (3)
Recovered from Wayback Machine