Use Masked Text Boxes

Problem

You want to have a fine-grained control over user text entry.

Solution

Use the masked ActiveX edit control, which can restrict and format data according to an input mask.

Discussion

The masked edit control looks like the text box control, but it includes enhancements for masked input and formatted output. If you don’t use an input mask, the masked edit control behaves like a standard text box.

To define an input mask, you set the Mask property with a string. The mask can include two types of characters: placeholders, which map to user supplied characters, and literal characters, which are entered automatically as the user types. The literal characters serve as visual cues that indicate the type of input that is being entered ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.