views:

46

answers:

2

What is the mask for "percentage", in a WinForms application (VB.net)?

+2  A: 

Per the documentation here: http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx

\ Escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash.

So the mask for a % sign is \%

Before posting, I made up a quick and dirty winforms app, tried it and it works.

Edit - added although this next item in the documentation makes it look like just a straight % sign should work without the backslash, so I tried it and it works as well.

All other characters Literals. All non-mask elements will appear as themselves within MaskedTextBox. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user.

David Stratton
A: 
textEdit1.Properties.Mask.MaskType = Numeric;
textEdit1.Properties.Mask.EditMask = "00.00%%";
textEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;

http://community.devexpress.com/forums/t/59535.aspx

Judas Imam
I doubt the OP is using a DevExpress control.
Hans Passant