I thought I'd add a little to this community. This may have been done before but I searched and didn't see this code. It's not stellar or ground breaking but it is very useful for me.
I use this function to determine if a value passed is a valid IP address or not.
VB Code:
' Verifies if Data qualifies as an IP address Function IsIP(IP As String) As Boolean 'Declarations Dim tmpIP As Variant Dim Element As Variant Dim x As Integer, y As String 'Verify 4 octets tmpIP = Split(IP, ".") If UBound(tmpIP) <> 3 Then IsIP = False Exit Function End If 'Verify all numerics tmpIP = Replace(IP, ".", "") For x = 1 To Len(tmpIP) y = Mid(tmpIP, x, 1) If Not IsNumeric(y) Then IsIP = False Exit Function End If Next x 'Verify octet values tmpIP = Split(IP, ".") For Each Element In tmpIP If Element > 255 Then IsIP = False Exit Function End If Next 'All tests passed IsIP = True End Function




Reply With Quote