Results 1 to 6 of 6

Thread: Resolved * Thank You* Textbox Arrays and Listboxes

  1. #1

    Thread Starter
    Addicted Member Renee K's Avatar
    Join Date
    Jun 2002
    Posts
    163

    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.

  2. #2
    Lively Member Professor29's Avatar
    Join Date
    Feb 2002
    Posts
    89
    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.

  3. #3
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    make your textboxes a control array and then when you click in one, the click event will TELL you which one was clicke in.

  4. #4

    Thread Starter
    Addicted Member Renee K's Avatar
    Join Date
    Jun 2002
    Posts
    163
    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.

  5. #5
    Lively Member Professor29's Avatar
    Join Date
    Feb 2002
    Posts
    89
    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.

  6. #6

    Thread Starter
    Addicted Member Renee K's Avatar
    Join Date
    Jun 2002
    Posts
    163
    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
  •  



Click Here to Expand Forum to Full Width