Form Text Box

  • Thread starter Thread starter krc547
  • Start date Start date
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
 
This works in a worksheet range:

Sub Numbfmt()
Range("C3").NumberFormat = "(###)###-###0"
End Sub
 
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
 
Back
Top