Mask Help

Hi All,
A quick and (for you guys, I’m sure) easy question. I just can’t get my head around masks for text boxes and I was going to ask how to create 3 masks - 1 for date format in dd-mm-yyy, 1 for time as hh:mm and a 3rd for currency as in $$,$$$.cc

Before posting I had a search for previous similar questions and was able to work out the first 2 -
##\-##\-#### and ##\:##, but for the life of me, I can’t seem to get the currency one. I try ##,###.## and 00,000.00 but they both FORCE the entry of numbers in those positions. I want something that will allow all entries from 99,999.00 to 0.01. I’ve even tried 999999 and 000000 with a view of formatting after the entry, but then you can’t enter the decimal point. I just can’t get it. Can it be done?


I use a custom control see here. The default validation mask “99999.99” works using NZ locale and does allow entry of the decimal character.

I gave up on masks a long time ago and wrote my own validation and formatting routines in KeyDown and LostFocus.


Have you tried:

  • Validation Mask: 99999.99
  • Format: 9,990.00

It will complain if you try to input 12,345.67, but seems to work if you type 12345.67 then Format converts the input to 12,345.67 on FocusLost.

Edit: if you need to allow the ‘,’ then you will need to write your own as Tim said.

Thanks for answering. I downloaded that file, but don’t know what to do with it. It won’t open in anything etc.
I should say, I’m just a hobbiest.

Hi Albert,
Thanks for that. Yes it does work, pretty simple huh? I was trying to have it automatically put the comma etc like I did with the colon in time or the slashes in dates. Sometimes you can overthink things :slight_smile:


Thanks Tim,
I got a working answer from another reply, but I like your idea as an exercise, I’m gonna give that a try at some point.


Just drag the file into your project.

Got it. Thanks, I’ll have a look :slightly_smiling_face:

Yeah thanks. Your original reply keeps me going, but I’ll have a look at Tim’s suggestion for the learning exercise.

Thanks everyone :blush: