Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

TextBox manipulation (Setting Focus)

Posted on 2003-03-05
4
Medium Priority
?
153 Views
Last Modified: 2010-08-05
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 :)
0
Comment
Question by:ANGmoh
4 Comments
 

Accepted Solution

by:
ProfFrink earned 150 total points
ID: 8071581
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
 

Expert Comment

by:Chaya
ID: 8071615
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
 
LVL 1

Author Comment

by:ANGmoh
ID: 8071803
Thanks for your help !
0
 
LVL 11

Expert Comment

by:Steiner
ID: 8071831
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

Featured Post

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!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

578 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