TextBox manipulation (Setting Focus)

Assuming i have 2 textboxes , if one of the textbox reaches it's maximum length ,it'll automatically setFocus to the another textbox , how can i do that ?

*something like when you installing windows , it requires you to enter the key ..and it'll jump to another text box when the key is filled .

Thanks in advanced :)
LVL 1
ANGmohAsked:
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.

ProfFrinkCommented:
in the first text box's keypress event

if(len(text1.text)+ 1)= intMaxLenght)then

text2.setfocus

end if

the "+1" after the len() is to account for the fact that the keypress event does not add the key value until the end of the event procedure.

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
ChayaCommented:
Place an array of textboxes on the form-text1(0),text1(1) etc.

Paste the following code:
Private Sub Form_Load()
    Dim i As Integer
   
    For i = 0 To Text1.UBound
        Text1(i).MaxLength = 6 'enter any length
        Text1(i).Text = ""
    Next i
End Sub

Private Sub Text1_Change(Index As Integer)
    If Len(Text1(Index)) = Text1(Index).MaxLength Then
        If Text1.UBound = Index Then
            MsgBox "all textbox filled!"
        Else
            Text1(Index + 1).SetFocus
        End If
    End If
End Sub
0
ANGmohAuthor Commented:
Thanks for your help !
0
SteinerCommented:
You can also use a component called Microsoft Masked Edit Control. That's some kind of textbox with some interesting features.
This one also has a feature called AutoTab which should do exactly what you want (+it sets the focus to the next object in the tab order, so inserting a new object is no problem).

Greets
Steiner
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.