VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



IP Address Validator

by Dr Morphin (8 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 10th February 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

IP Address Validator

API Declarations


' Put On Comnand Button on your projcet

Rate IP Address Validator



    Dim i As Integer
    Dim dot_count As Integer
    Dim test_octet As String
    Dim byte_check
     IP = Trim$(IP)

 
     If Len(IP) < 8 Then
        Valid_IP = False

        MsgBox IP & " is Invalid", , "IP Validator"
        Exit Function
    End If

    i = 1
    dot_count = 0
    For i = 1 To Len(IP)
        If Mid$(IP, i, 1) = "." Then
      
            dot_count = dot_count + 1
            test_octet = ""
            If i = Len(IP) Then
            
                Valid_IP = False
          
                MsgBox IP & " is Invalid", , "IP Validator"
                Exit Function
            End If
        Else
            test_octet = test_octet & Mid$(IP, i, 1)
            On Error Resume Next
            byte_check = CByte(test_octet)
            If (Err) Then
               
                Valid_IP = False
                Exit Function
            End If
        End If
    Next i
   
    If dot_count <> 3 Then
        Valid_IP = False
        Exit Function
    End If
     
    Valid_IP = True

        MsgBox IP & " is Valid", , "IP Validator"
    
End Function

Private Sub Command1_Click()
    If Len(Text1) = 0 Then
        MsgBox "Please type an IP Address in the textbox.", , "IP Validator"
    Else
       
        Valid_IP Text1
    End If
End Sub

Download this snippet    Add to My Saved Code

IP Address Validator Comments

No comments have been posted about IP Address Validator. Why not be the first to post a comment about IP Address Validator.

Post your comment

Subject:
Message:
0/1000 characters