Commands in Visual Basic #2
1) Combo Boxes – Allow the user to elect a value from a list in the box, or to input their own value. If the user does not need to input unique values, use a list box instead.
A) To add items to the box – Under Data – Items
Click on Items to get a box where you can enter values to add to your box
B) To use a value in the Combo Box : Just refer to : Combobox1.text
So that :
Label1.text = combobox1.text
OR
Label1.text = formatcurrency(combobox1,2)
2) List Boxes – will be seen as an array of choices. To access, they begin at index=0 and go from there.
*Note that you can also determine how many items can be selected:
Under Behavior: Selectionmode – None, One, Multsimple or MultExtended
A) To add items to the box
Click on Data-Items to get a box where you can enter values to add to your box
OR
Objects can be added to your box during run time using code – but these changes are NOT permanent. Most of these are also done using methods of the items, not the listbox.
Listbox1.items.add(text) -
Listbox1.items.insert(position, text) -
Listbox1.items.remove(“text”) Removes the first item that matches the text
Listbox1.items.removeat(position) – removes an item in a specific location
Listbox1.items.clear() – deletes all the items in the box
B) To use values in the box – depends on if you want to use it for a calculation
listbox.selecteditem – returns the string in the list that was selected
listbox.selectedindex – returns the index number selected
listbox.list(index) – returns the item at that location
3) Check boxes – You can check to see if they are checked or not, then make the decision in the code as to what to do.
Checkbox1.checked = true
4) Radio buttons – add to a group box. Then you can check which radio button is checked (if any).
if radiobox1.checked = true then
stmts…
endif