?
Solved

TextBox manipulation (Setting Focus)

Posted on 2003-03-05
4
Medium Priority
?
149 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
[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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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