VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This function validates a website's address.

by Doongoor Navindresingh (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 28th April 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This function validates a website's address.

Rate This function validates a website's address.



Dim lngIndex As Long
Dim lngCountDot As Long
Dim strCurrentChar As String

ValidateAddress = True
lngCountDot = 0
'If address is not at least www.y.com long
strAddress = LCase(Trim(strAddress))
If Len(strAddress) < 9 Then GoTo Fail_Validation

If Left(strAddress, 4) <> "www." Then GoTo Fail_Validation

Select Case Right(strAddress, 4)
    Case ".com", ".org", ".net", ".edu", ".mil", ".gov"
        ' Yes, it's valid.
    Case Else
        GoTo Fail_Validation
End Select

For lngIndex = 1 To Len(strAddress)
    strCurrentChar = Mid(strAddress, lngIndex, 1)
    
    If strCurrentChar = "." Then lngCountDot = lngCountDot + 1
    Select Case Asc(strCurrentChar)
        Case 65 To 90, 97 To 122, 48 To 57, 45, 46
         'Yes, it's valid
        Case Else
            GoTo Fail_Validation
        
    End Select
Next lngIndex

If lngCountDot > 2 Then GoTo Fail_Validation

ValidateAddress_Exit:
    Exit Function

Fail_Validation:
    ValidateAddress = False
    GoTo ValidateAddress_Exit
End Function



Download this snippet    Add to My Saved Code

This function validates a website's address. Comments

No comments have been posted about This function validates a website's address.. Why not be the first to post a comment about This function validates a website's address..

Post your comment

Subject:
Message:
0/1000 characters