Private Sub cmdEnter_Click() Dim arrayErr(1 To 5) As Boolean Dim i As Integer Dim code As String Dim Error As Boolean Dim ch1, ch2, ch3, ch4, ch5 As String * 1 Dim Length As Integer Dim Index As Integer code = txtInput.Text Length = Len(code) For Index = 1 To 5: arrayErr(Index) = False: Next Index Error = False If Length = 0 Then MsgBox "Empty String is not allowed" Error = True Else If Length <> 5 Then MsgBox "The string should be 5 characters long" Error = True Else ch1 = Mid(code, 1, 1) ch2 = Mid(code, 2, 1) ch3 = Mid(code, 3, 1) ch4 = Mid(code, 4, 1) ch5 = Mid(code, 5, 1) If ch1 < "0" Or ch1 > "9" Or ch2 < "0" Or ch2 > "9" Then arrayErr(1) = True If ch1 < "A" Or ch1 > "Z" Or ch2 < "A" Or ch2 > "Z" Then arrayErr(2) = True End If Else arrayErr(2) = True End If If ch3 < "0" Or ch3 > "9" Then arrayErr(3) = True If ch4 < "0" Or ch4 > "9" Then arrayErr(4) = True If ch5 < "0" Or ch5 > "9" Then arrayErr(5) = True If arrayErr(1) And arrayErr(2) Then MsgBox "Invalid country" Error = True Else If arrayErr(1) Then MsgBox "Overseas Centre" Else MsgBox "UK Centre" End If End If For i = 3 To 5 If arrayErr(i) Then MsgBox "Invalid " & i & "th character" Error = True End If Next i If Error Then MsgBox "Invalid code" Else MsgBox "Valid code" End If End If End If End Sub