I prefer not to bother users with messageboxes as if they did something 'wrong'. It also slows the ease with which a user uses your application.
Based on the example in your first post:
Private Sub TextBox1_Change()
' Application.EnableEvents = False
With TextBox1
Select Case Len(.Text)
Case 1, 2
.Text = UCase(.Text)
If Asc(Right(.Text, 1)) < 65 Or Asc(Right(.Text, 1)) > 91 Then .Text = Left(.Text, Len(.Text) - 1)
If Len(.Text) = 2 Then .Text = .Text & "-"
Case 4 To 11, 13 To 16
If Val(Right(.Text, 1)) = 0 Then .Text = Left(.Text, Len(.Text) - 1)
If Len(.Text) = 11 Then .Text = .Text & "-"
End Select
End With
' Application.EnableEvents = False
End Sub
Bookmarks