boolean = IsZip(zipcode)
Example Usage:
ASP Source Code:<% ' IsZip returns true response.write IsZip(14450) & "<BR>" response.write IsZip(10036) & "<BR>" response.write IsZip("31200-6514") & "<BR>" ' IsZip returns False response.write IsZip(6500) & "<BR>" response.write IsZip(112012) & "<BR>" response.write IsZip("3154-88542") & "<BR>" response.write IsZip("1152A-0SDX") & "<BR>" %>
<% Private Function IsZip(byVal zipcode) Dim reg if IsNull(zipcode) then IsZip = False exit function elseif IsEmpty(zipcode) then IsZip = False exit function end if zipcode = Trim( CStr( zipcode ) ) Select Case Clng( Len(zipcode) ) Case 10 Set reg = New RegExp With reg .IgnoreCase = True .Global = True .Pattern = "[0-9][0-9][0-9][0-9][0-9]" & _ "-[0-9][0-9][0-9][0-9]" If .Test(zipcode) Then IsZip = True Else IsZip = False End If End With Set reg = Nothing Exit Function Case 5 Set reg = New RegExp With reg .IgnoreCase = True .Global = True .Pattern = "[0-9][0-9][0-9][0-9][0-9]" If .Test(zipcode) Then IsZip = True Else IsZip = False End If End With Set reg = Nothing Exit Function Case Else IsZip = False Exit Function End Select End Function %>