items of comboboxes

kwijibo
07-05-2002, 02:56 PM
hi

how can i assign a number to a variable depending upon what is selected on a combo box??

eg.

if combobox =item1 then
var.item=1
etc.

and how can i do the vice versa - ie. set the item of a combobox depending upon the number in a variable?

eg.

if var.item=2 then
combobox=item
etc

BillSoo
07-05-2002, 03:03 PM
Try setting/reading the combobox.listindex property

Robby
07-05-2002, 03:07 PM
here's a simple example of assigning an index number to items in a combo...


Private Sub Combo1_Click()
MsgBox Combo1.ListIndex
End Sub

Private Sub Form_Load()
with Combo1
.AddItem "aaa", 0
.AddItem "bbb", 1
.AddItem "ccc", 2
.AddItem "ddd", 3
end with
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum