Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

tabbing from one mask edit to another automatically

Posted on 1998-07-01
12
Medium Priority
?
155 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.
0
Comment
Question by:sharons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 1

Expert Comment

by:michaue
ID: 1356879
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;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356880
michaue, Did you check it?
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356881
Yes, Why?  :)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:ronit051397
ID: 1356882
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356883
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356884
Because if you put some mask then it's not working. Put the following mask:
MaskEdit1.EditMask:='!\(999\)000-0000);1;_'
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356885
Sorry, I didn't check it with the mask ....
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356886
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;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356887
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.
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356888
Any suggestions ?
0
 
LVL 3

Accepted Solution

by:
vladika earned 200 total points
ID: 1356889
Try it

procedure TForm1.MaskEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if MaskEdit1.SelStart = MaskEdit1.MaxLength then MaskEdit2.SetFocus;
end;

0
 

Author Comment

by:sharons
ID: 1356890
It works great.  Thank you.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question