I have several drop lists on my form, with either numbers or names on them. I want to change it so each item on the drop list has a certain "value" to it. For example, if a was "1" on my first drop list and hello was "23", wen I select "a" and "hello" from the list and I click calculate, it will do the mathematical equation of 1*23. Is there any way?
I have no idea, but I think both of you are right. Prozeen, can you please explain how the listbox property works? My file should look like this, to make my situation more clear.
Private Sub Command1_Click()
MsgBox Combo1.ListIndex + 1 & "*" & Combo2.ListIndex + 1
End Sub
Private Sub Form_Load()
With Combo1
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
With Combo2
.AddItem "welcome"
.AddItem "to"
.AddItem "vb"
.AddItem "programming"
End With
End Sub
Now its really too much. The code is so simple ,very basic level . How do u expect all the spoon feeding after being provided with alll the sample code on a free forum like this.
Thanks Debashis. I appreciate your reply. But I think I can explain this too. Hope you will recognize that.
n louislam 123 here are explanations. go through it......
the code in the form_load event simply adds some elements in the two combo boxes.three elements in combo1 and four elements in combo2.
now the code in command1_click event :-
whenver you select an item from both the combo boxes it will trap the index value for the selected item and add 1 to it,so that it can be looked as real numbers.hope u know that the combo box is a sort of array and the elements stored in an array is identified by its position no.,also known as index or subscript value and this index value always starts from 0.so,when you select the first item in the combo1 the event will trap its index as 0 and add 1 to it.so,it will become 0+1=1.same thing is for combo2 also.after this the code will just concate the two resulted index values and put an asterix between them.
hope the above explanation is enough for you to understand the logic behind this coding.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.