Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / Visual Basic
Article

Masked Edit Box in vb.net

Rate me:
Please Sign up or sign in to vote.
2.24/5 (12 votes)
29 Oct 2004 124.4K   2.6K   22   6
Simple but flexible Masked Edit Box

Sample Image - MaskedTextBox.jpg

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.

 

 

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Dave Kreskowiak2-Oct-09 8:38
mveDave Kreskowiak2-Oct-09 8:38 
GeneralRead only Pin
AJR 11217-May-06 10:17
AJR 11217-May-06 10:17 
GeneralCauses exception Pin
ingotaner25-Jan-06 4:54
ingotaner25-Jan-06 4:54 
GeneralIt has wha I need Pin
msxkim2-May-05 4:42
msxkim2-May-05 4:42 
GeneralBad :( Pin
Pablo Robert3-Feb-05 10:45
Pablo Robert3-Feb-05 10:45 
I downloaded your control. Installed in my toolbox and the first char I typed I got an exception.

Really bad Cry | :((

Pablo Robert
GeneralI am not getting this Masked Edit Box Pin
Manish Kaushik12-Jan-05 19:51
Manish Kaushik12-Jan-05 19:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.