Can someone tell me please if I add a combo box to a blank fresh application, how do I add data to the combo box, so when I run it, and press the drop down there are e.g. 5 keywords in there?
Thank you.
Printable View
Can someone tell me please if I add a combo box to a blank fresh application, how do I add data to the combo box, so when I run it, and press the drop down there are e.g. 5 keywords in there?
Thank you.
Where is the data that will be in the combo being stored?
Like this:Quote:
Originally Posted by jokerfool
vb Code:
With Combo1 .AddItem "Keyword 1" .AddItem "Keyword 2" .AddItem "Keyword 3" .AddItem "Keyword 4" .AddItem "Keyword 5" End with
Let me know if you will be loading your data from a database and I will show you how to do it.
Okay I am not so hot at using this vb6, but I was hoping that data was just stored in the form, I say this because I have another form that contains hundreds of websites and all the websites are listed in the form, so was just wanting the same thing.
hmmmm so I place the combo box down, double click it and do I just add the above like this:
Code:Private Sub Combo1_Change(Index As Integer)
With Combo1
.AddItem "Keyword 1"
.AddItem "Keyword 2"
.AddItem "Keyword 3"
.AddItem "Keyword 4"
.AddItem "Keyword 5"
End With
End Sub
Quote:
Originally Posted by jokerfool
How are you "storing" the data on the other form? Could you post your project? Exactly, what data are you looking to "store" in the combobox?
the data in the combo box will only be keywords and random keywords e.g.
dog
cat
fish
lion
wolf
"Storing" the keywords in the form means hard coding them.
If you ever want to change them or add to them you would need to modify the source code, recompile the program, and redistribute it.
Yes I understand this and I know its the hard way but I dont know any other way of doing it, not without someone teaching me how to do this.
Ive scoured the forum and googled all sorts of answers and comeup with this from creating a combo box ( drop down ) combo1 and combo2:
Yes this is the hard way but I know of no other way.Code:Private Sub Form_Load()
Combo1.AddItem "dog"
Combo1.AddItem "cat"
Combo1.AddItem "fish"
Combo1.AddItem "people"
Combo1.AddItem "humans"
Combo1.AddItem "plants"
Combo2.AddItem "12345"
Combo2.AddItem "hello"
Combo2.AddItem "abcde"
Combo2.AddItem "counting"
Combo2.AddItem "websites"
Combo2.AddItem "frog"
End Sub
Use a database. They can be dynamically updated without changing any of your code.
We have a ton of database examples in our FAQ section as well as database tutorials.
Okay will do, thank you for the assistance. One last question in a new thread, thank you.