hi, i cant do my codes on how a combo1(i) will do its command when clicked,

i have 10 combo box that have index from 1 to 10 on my form, when combo1(1) was clicked, it will do my command to that combo1(1) only not in combo1(2),combo1(3) ... to combo1(10)


when combo1(1) was clicked , it will show my age
when combo1(2) was clicked , it will show my name
when combo1(3) was clicked , it will show my address

3 Years
Discussion Span
Last Post by rishif2

you'll need to use if statements

on the click event put the following code:-

Private Sub Combo1_Click(Index As Integer)
If Index = 1 Then 
MsgBox "your age" 
Else If Index = 2 Then 
MsgBox "you name" 
Else If Index = 3 
Then MsgBox "you address" 
MsgBox "soemthing other"
End if
End Sub

i assume that you are familiar with combobox's events. And dont be confused in clicked , changed , gotfocus etc.
i also assume that you know when the chage event fires and when the click event fires.

if you wanna show age , name , sex by clicking only combobox not selecting their items from list then i think you'll have to write the to gotfocus() event otherwise write the code to click event.

hope this helps . . .

Edited by rishif2


its ok now but my other problem was , when a combo1 text was change it will trigger to show the whole info in the label.


combo1 text = "" then become my name then
label 1 will become my name too


First off , not sure for what you asking .

but , if you change text by type to combobox then combo1_change() fires
just put

if index=1 Then
Label1.caption="show your age"
End if

further you can add more conditions using ElseIf.

if still having problems then try to define it in more clear way.

And finally , it will be very easy for us to provide any assistance if you provide what you did for that(i mean the code) ?

Edited by rishif2

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.