Form Text Box

K

krc547

How do i get a text box on a form to only allow a certain way to fill the box
in. Such as a text box for a phone number and I want the input to be limited
to look like the following:

(555)555-5555
 
J

JLGWhiz

This works in a worksheet range:

Sub Numbfmt()
Range("C3").NumberFormat = "(###)###-###0"
End Sub
 
J

john

untested but something like this may work:

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Text) Then
If Len(TextBox1.Text) = 10 Then
mynum = Format(TextBox1.Text, "(###)###-###0")
TextBox1.Text = mynum
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top