Auto Tab to next Textbox

I am creating 3 textboxes so a user can type in a social security number (SSN).  I have set the MaxLength to the 1st textbox to 3 (for the first 3 digits of the SSN).  How can I make the cursor automatically tab to the second box once the MaxLength has been reached? (For example: I want it to perform exactly like entering an Installation key of any product)
ahelgesonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zacharCommented:
Use the following code on the 1st text box 'Change' event:

If Len(TextBox1.text)=3 then TextBox2.SetFocus

or better, if the max lenth will be changed in the future:

If Len(TextBox1.text)=TextBox1.MaxLenth  then TextBox2.SetFocus

Good luck.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rovermCommented:
Quite easy:

Build a new standard VB project,
place 3 textboxen on the form (text1-3) and set each maxlength to 3 and clear the text property.
Then paste this code:

Private Sub Text1_Change()
    If Len(Text1.Text) = Text1.MaxLength Then SendKeys "{TAB}"
End Sub

Private Sub Text2_Change()
    If Len(Text2.Text) = Text1.MaxLength Then SendKeys "{TAB}"
End Sub

Private Sub Text3_Change()
    If Len(Text3.Text) = Text1.MaxLength Then SendKeys "{TAB}"
End Sub

This way you can make it an indepentant TAB, you don't have to know design time which text box is next.

grtx, RoverM
0
Seven priceFull StackCommented:
question on this where do you declare the SendKeys
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.