Validates ZIP code
Validates ZIP code
Rate Validates ZIP code
(2(2 Vote))
' Purpose: Checks to see if strZIP is in the format of a valid ZIP code.
' In: strZIP - Candidate ZIP code
' Out:
' Returns: True - if strZIP is in the format of a valid ZIP code
' False - if it is not
' Date: 1/16/2000
' Programmer: Speed Demon
' Last Modified:
' Notes: ZIP codes can be in the form 'xxxxx' or 'xxxxx-xxxx' where x is numeric.
' Assume it is a valid zip
ValidateZIP = True
Select Case Len(strZIP)
Case 5 ' xxxxx
If Not IsNumeric(strZIP) Then ValidateZIP = False
Case 10 ' xxxxx-xxxx
If Not IsNumeric(Left$(strZIP, 5)) _
Or Not IsNumeric(Right$(strZIP, 4)) _
Or Mid$(strZIP, 6, 1) <> "-" Then ValidateZIP = False
Case Else ' strZIP does not contain the right number of characters.
ValidateZIP = False
End Select
End Function
Validates ZIP code Comments
No comments yet — be the first to post one!
Post a Comment