In Visual Basic 6 there are many object can we use to developt program that we want to built. One of it is combobox, combobox is object that provide data as list when we click the data that we set will be show and we choose one data of much data in the list for process in the future.
So how the wat to set data in the object of combobox? Its will become the main question for us. There are 2 ways to set data in the object of combobox, here are:
- After you pairs the combobox on the form, move to code area and choose event that you want the data will be set, usually set data in the object set when form loaded.
- After that to add item you just code like this :
box.AddItem item[, index]
Box is Name of combobox that you pairs in your form
AddItem is function of this object to add item
item[, index] is name would appear in the list
for example :
Private Sub Form_Load () Combo1.AddItem "Muhamad" Combo1.AddItem "Ade" Combo1.AddItem "Lukmanul" Combo1.AddItem "Hakim" End Sub
- If we dont want spend effort to write code, we can use the properties GUI to add item to the combobox, choose the object of combobox
- Looking up to properties area, usually in the right side of vb6. And search the List attribute. Like in the image
- After that you just click that atribut and type the data want you add, enter to make sure the data entered