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

x

tabbing from one mask edit to another automatically

sharons
sharons asked
on
Medium Priority
164 Views
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.
Comment
Watch Question

Commented:
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
  MaskEdit2.SetFocus;
michaue, Did you check it?

Commented:
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:
MaskEdit1.EditMask:='!\(999\)000-0000);1;_'

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

Commented:
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
  MaskEdit2.SetFocus;
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.

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

Author

Commented:
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.

OR

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.