We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


tabbing from one mask edit to another automatically

sharons asked
Medium Priority
Last Modified: 2010-04-04
the users of my application have to enter 2 numbers in two separate mask edit fields. These are numeric values. I would like the focus to jump to the second mask edit when the first one is filled with digits (sort of like the Windows 95 authentication code.
Watch Question

Set the MaxLength property of MaskEdit1 (at design time) to the maximum number of digits you want entered into the field.

And on the OnKeyUp event of MaskEdit1 put the following code

if Length(MaskEdit1.Text) = MaskEdit1.MaxLength then
michaue, Did you check it?

Yes, Why?  :)
michaue, Did you check it?
michaue, Did you check it?
Because if you put some mask then it's not working. Put the following mask:

Sorry, I didn't check it with the mask ....

Here's the sollution with mask edit characters included:

You have to declare a variable to hold the character count, and initialize it with the value of mask characters for which the user won't enter anything (like spaces etc)

You don't have to set the MaxLenght property when you add and EditMask to MaskEdit1, because it will put the value in as soos as you change the EditMask property.

Then in the KeyPress event of MaskEdit1 put the following code ...

Count := Count + 1;
if Count = MaskEdit1.MaxLenght then
But then if you are pressing the left arrow key, meaning going back, then the Count will not have the right value of the cursor position, so in this case it will not work properly.

Any suggestions ?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


It works great.  Thank you.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.