Mr_Fulano
asked on
Input Mask for a Textbox.
Hi, I'm using VB 2005, WinForms. I have two Textboxes on my Form that contain telephone numbers. My Database Table has an input mask for these fields that put the phone numbers into the following format: (999) 999-9999.
How can I do the same with a Textbox? Would I have to write code to determine which number position is being entered and then assign the proper formatting, or is there a telephone number mask, like the password character mask, that can be applied here in some way?
Thanks,
Fulano
How can I do the same with a Textbox? Would I have to write code to determine which number position is being entered and then assign the proper formatting, or is there a telephone number mask, like the password character mask, that can be applied here in some way?
Thanks,
Fulano
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
there is not a telephone number mask but there is a control that support masks: MaskedTextBox. Just use it instead of TextBox, and set the Mask property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx
Screenshot showing what I am talking about.
untitled.PNG
untitled.PNG
ASKER
Very good and simple solution.
ASKER
Thanks to all, but Sh0e had the best solution of all, which is what I needed. I actually didn't even know this control existed! Wow, live and learn...this is why I like this forum so much!!!
http://www.codeproject.com/KB/cpp/ValidText.aspx
http://www.codeproject.com/KB/cpp/maskedbox_control.aspx
http://www.codeproject.com/KB/cpp/cpflexmaskeditbox.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.validatingtype(VS.80).aspx
Regards,
M.Raja