1,105,254 Community Members

Array Combobox

Member Avatar
jemartalaban_1
Light Poster
49 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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)

example

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

Member Avatar
tinstaafl
Postaholic
2,012 posts since Jun 2010
Reputation Points: 559 [?]
Q&As Helped to Solve: 402 [?]
Skill Endorsements: 35 [?]
 
0
 

Show the code for the event handler

Member Avatar
rishif2
Posting Whiz in Training
284 posts since Dec 2012
Reputation Points: 57 [?]
Q&As Helped to Solve: 58 [?]
Skill Endorsements: 4 [?]
 
1
 

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" 
Else 
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 . . .

Member Avatar
jemartalaban_1
Light Poster
49 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

example

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

Member Avatar
tinstaafl
Postaholic
2,012 posts since Jun 2010
Reputation Points: 559 [?]
Q&As Helped to Solve: 402 [?]
Skill Endorsements: 35 [?]
 
0
 

Without conditional code to decide when you want it to change, the change will always occur.

Member Avatar
rishif2
Posting Whiz in Training
284 posts since Dec 2012
Reputation Points: 57 [?]
Q&As Helped to Solve: 58 [?]
Skill Endorsements: 4 [?]
 
0
 

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) ?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article