Masked Edit Box in vb.net






2.24/5 (12 votes)
Oct 29, 2004

125166

2657
Simple but flexible Masked Edit Box
Introduction
This is a very easy to use Masked TextBox for fixed length strings like phone numbers, social security, driver license, etc. Not suitable for values as it is but you can customize it.
Details
- The "#" character in the mask is used for digit only
- The "&" character accepts letter only
- The "!" character accepts letter or digit
- You can use any mask symbol, letter and digit other than # & and !
Ex. ###-&!/&&(###) ###-!!!! &&XXX##Z12&&&
Using Component
The use of this component is very simple. You have to select the toolbox panel, right click in the windows forms section and select customize toolbox.
Select .NET framework components, then click browse and select maskedtextbox.dll in the download path. The maskedbox component will appear at the end of windows forms panel. Now select the component and drop it on a form.
Then set the mask property with any combination of characters
At run time you can read the unformatedtext property to read only the user input.
The Text property returns the formated string.