[COLOR="DarkGreen"]'Test Length is OK[/COLOR]
If Len(Me.TestString) <> 8 Then
MsgBox "Input must be eight characters long in the form Two Letters, Five Numbers and One Letter"
Cancel = True
Exit Sub
End If
Dim x As Integer
[COLOR="DarkGreen"]
'Loop through each position and test for numeric or string[/COLOR]
For x = 1 To 8
Select Case x
[COLOR="DarkGreen"]'Test positions 1, 2, and 8 for string charterer[/COLOR]
Case 1, 2, 8
If IsNumeric(Mid(Me.TestString, x, 1)) = False Then
If Asc(Mid(Me.TestString, x, 1)) < 65 Or Asc(Mid(Me.TestString, x, 1)) > 90 Then
If Asc(Mid(Me.TestString, x, 1)) < 97 Or Asc(Mid(Me.TestString, x, 1)) > 122 Then
MsgBox "Charterer " & x & " must be a Letter between A to Z"
Cancel = True
Me.TestString.SelStart = x - 1
Me.TestString.SelLength = 1
Exit Sub
End If
End If
End If
[COLOR="DarkGreen"]
'Test all other positions for numeric chartere[/COLOR]r
Case Else
If IsNumeric(Mid(Me.TestString, x, 1)) = False Then
MsgBox "Charterer " & x & " Must be Numeric"
Cancel = True
Me.TestString.SelStart = x - 1
Me.TestString.SelLength = 1
Exit Sub
End If
End Select
Next x