Results 1 to 3 of 3

Thread: linking combobox and textbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    7
    I have designed a study quide for a test which consists of
    65 multiple choice terms and their definitions. I put the terms in a combobox and want the corresponding definition to appear in the textbox as the user selects it.

    First, I declared 2 arrays in General Declarations:
    Dim Question(100), Answer(100)

    Next, under Form_Load

    Question(1) = " 1st term "
    Question(2) = "2nd term" etc....

    Answer(1) = " 1st answer"
    Answer(2) = " 2nd answer"

    My question is: What code can I use to cause the definition to be entered into the textbox as the user selects it.

    Thanks for any help!

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    Code:
    'change the dimensions accordingly
    'I am using an array of 2
    
    Option Explicit
    
    Dim Question(1), Answer(1)
    
    Private Sub Combo1_Click()
        Dim x
        x = Combo1.ListIndex
        Text1.Text = Answer(x)
    End Sub
    
    Private Sub Form_Load()
        Question(0) = " 1st term "
        Question(1) = "2nd term"
        
        Answer(0) = " 1st answer"
        Answer(1) = " 2nd answer"
        
        Dim i As Integer
        For i = 0 To 1
          Combo1.AddItem Question(i)
        Next i
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    7
    Thanks for your prompt reply, I'll try the code!

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