|
-
Oct 2nd, 2002, 04:49 PM
#1
Thread Starter
Addicted Member
Resolved * Thank You* Textbox Arrays and Listboxes
I am fairly new to arrays, and try to avoid them because I always get stuck in positions like this.
I have and array of 8 textboxes and by double clicking on any of the textboxes a list box will appear. Well my problem is how do I put the listbox selection into the textbox it was called from, and how do I set focus back to the textbox?
Code:
Private Sub lstCode_DblClick()
For i = 0 To lstCode.ListCount - 1 'Loop to find selection
If lstCode.Selected(i) = True Then 'If selected
For j = 0 To txtCode.Count - 1
'******************************************
'NEED TO DETERMINE HOW TO PLACE SELECTED VALUE IN
'ORIGINAL TEXT BOX
'******************************************
If txtCode(j). Then
txtCode(j).Text = lstCode.Text 'Display selection
End If
Next j
End If
Next i
lstCode.Visible = False 'Hide lstbox
'***************************************
'NEED TO SET FOCUS BACK TO ORIGINAL TEXT BOX
'******************************************
For j = 0 To txtTestCode.Count - 1
txtTestCode(j).SetFocus
Next j
End Sub
Thank you
Last edited by Renee K; Oct 2nd, 2002 at 05:07 PM.
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
-
Oct 2nd, 2002, 04:51 PM
#2
Lively Member
Just store the index of the dblclicked text box into a global variable and use that variable to access the proper text box.
ERROR: No keyboard detected. Hit F1 to continue.
-
Oct 2nd, 2002, 04:53 PM
#3
PowerPoster
make your textboxes a control array and then when you click in one, the click event will TELL you which one was clicke in.
-
Oct 2nd, 2002, 04:57 PM
#4
Thread Starter
Addicted Member
Thanks for the response.
The text boxes are already like txtCode(0).text and so on. So when I am going through the for loop how do I know which one to stop on?
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
-
Oct 2nd, 2002, 05:01 PM
#5
Lively Member
You said that dbl clicking the text box makes the list box visible, right? If that's true, a public variable should solve it. Public variables can be accessed on other forms and modules, so long as you use the name of the form it was created in. You shouldn't have to use the for loop, just get the value you stored.
ERROR: No keyboard detected. Hit F1 to continue.
-
Oct 2nd, 2002, 05:06 PM
#6
Thread Starter
Addicted Member
I finally got it thank you all for your help and your patience.
.·*¨) ¸.·*¨) ¸.·*¨*
(¸.*´ ¸.·´*'~*Renee~* (¸.*´~*
Funny how the little things can stop you dead in your tracks. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|