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.
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.
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..
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.