Results 1 to 5 of 5

Thread: Combo Box

  1. #1

    Thread Starter
    Hyperactive Member tomjess's Avatar
    Join Date
    Mar 2001
    Location
    Hamilton, New Zealand
    Posts
    348

    Combo Box

    Help, I am going around in Circles.

    Please, can someone give the exact code, so that the user can enter text in the Combo box and it remains there, ie if the user enters "DATA" in text in the combo box, next time the user drops down the combo "DATA" is there. I can do it but when the program runs again all the text added has been lost.

    Thanks, you guys and lasses

  2. #2
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485

    Assuming your ComboBox's properties are in default condition

    Code:
    Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
      If KeyCode = vbKeyReturn Then
        Combo1.AddItem Combo1.Text  'Add text into combo1
        Combo1.Text = ""            'Clears the entered text
      End If
    End Sub
    Key in the text you want to add, then press Enter key to add.
    Added text will be at the bottom of the list.

    This will add duplicate entries though, you'll need to cycle through the list to skip adding duplicates.

    Good Luck

    Harddisk
    Last edited by Harddisk; May 9th, 2001 at 02:18 PM.

  3. #3
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    OK.

    I did it and it seems to work.
    Just type something in the combobox
    and press return. Then check the combo
    to see if it was added.
    After that quit the program, then start
    it again.
    The items should be there..

    note: adds up to 10 items.

  4. #4
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Opps.

    Here is the file. Its zipped.
    Attached Files Attached Files

  5. #5
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    code:--------------------------------------------------------------------------------
    Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    Combo1.AddItem Combo1.Text 'Add text into combo1
    Combo1.Text = "" 'Clears the entered text
    End If
    End Sub
    --------------------------------------------------------------------------------


    Key in the text you want to add, then press Enter key to add.
    Added text will be at the bottom of the list.

    This will add duplicate entries though, you'll need to cycle through the list to skip adding duplicates.

    Good Luck

    Harddisk
    I do believe he added item, but then when he went to the program
    next time they were lost. So this code will not work.

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