Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Input Mask in Visual Basic

Status
Not open for further replies.

eelsar

Technical User
May 20, 2002
36
US
I know there is an option in Access to input mask something, for example a phone number. Using the input mask the user would only be able to enter a number in the format of (###)###-####. When the user clicks on field to enter the number it looks the following
(_ _ _)_ _ _ - _ _ _ _
Is this possible to do in Visual Basic? How would I do this?
Thank you!
 
This is one way to do it with a regular text box. Drop this code in a form with a text box and a command button

Private Sub Command1_Click()
Text1.Text = "1234567890"
End Sub

Private Sub Text1_Change()
Text1.Text = Format$(Text1.Text, "(###) - ### - ####")
End Sub

Or there is a control called the MS Masked Edit control that you can add from the components under the project menu where you can just add your (###) - ### - ####) format to either the mask property or the format property depending on the results you are looking for.

Hope this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Or use StdFormat.... *******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top