PDA

View Full Version : number format



mortred
11-03-2009, 09:27 AM
how can i format a textbox which
starts with specific letter that should be Uppercase and followed by 4 digit numbers.

ex. A1115

Krishna Kumar
11-03-2009, 10:18 AM
Hi,

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Const Ptrn As String = "[A-Z]####"
If Len(Me.TextBox1) Then
If Not Me.TextBox1 Like Ptrn Then
MsgBox "Invalid", vbInformation + vbCritical
Me.TextBox1.Value = ""
Exit Sub
End If
End If
End Sub

mortred
11-04-2009, 04:38 AM
thank you!
the code works the way i wanted