Function Validate(InString As String) As Boolean
'-- Checks that InString is in the format A99-99-99-9
Dim i As Integer
Validate = False '-- Default to bad validation
If Len(InString) = 11 Then
For i = 1 To 11
Validate = ValidatePosition(Mid(InString, i, 1), i)
If Not Validate Then
Exit For
End If
Next i
End If
End Function
Function ValidatePosition(InChar As String, InPosition As Integer) As Boolean
'-- Positional Validation to be used with the Validate() function.
ValidatePosition = False '-- Initialize as failure
Select Case InPosition
Case 1
If UCase(InChar) >= "A" And UCase(InChar) <= "Z" Then
ValidatePosition = True
End If
Case 4, 7, 10
If InChar = "-" Then
ValidatePosition = True
End If
Case Else
If InChar >= "0" And InChar <= "9" Then
ValidatePosition = True
End If
End Select
End Function