View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2002_] Rick Rothstein \(MVP - VB\)[_2002_] is offline
external usenet poster
 
Posts: 1
Default Textbox validation

What exactly do you mean by "restrict textbox"? If you are talking about
"approving" an entry when the user tries to leave the TextBox, then you can
use something like this...

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not TextBox1.Text Like "[A-Za-z][A-Za-z][A-Za-z] ##" Then
Cancel = True
MsgBox "Your entry is not in the proper format!"
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
End If
End Sub

If you have something else in mind when you say "restrict", you are going to
have to tell us what it is that you want to do.

Rick


wrote in message
...


Hi,

How to restrict textbox in userform for the following entry

SEP 08

I mean first three cheractors Alphabatic and space and two cheractors
number.

Regards.

Shahzad