|
-
Mar 11th, 2004, 12:07 PM
#1
Thread Starter
Junior Member
Selecting an item in ComboBox
How do I select the item in the ComboBox. The selected item will determine what will be inserted in ComboBox2.
-
Mar 11th, 2004, 12:18 PM
#2
Lively Member
you could use this
Code:
private sub command1_click
dim item as string
item = combo1.text
combo2.additem string
end sub
let me know if thats not what you wanted
Last edited by beowulf; Mar 11th, 2004 at 12:22 PM.
-
Mar 11th, 2004, 12:19 PM
#3
Lively Member
the .ListIndex property moves to an entry
combo1.List(x) property returns the text.
combo1.list(combo1.listindex) returns the selected item.
-
Mar 11th, 2004, 12:23 PM
#4
I think something like this is what he wants.
Combo1.ListIndex = 2
-
Mar 11th, 2004, 12:23 PM
#5
Thread Starter
Junior Member
Where should I put these codes?
in the Combo1_Click? or Combo2_Click?
when combo1 item is selected, it will determine the items to be added into combo2.
-
Mar 11th, 2004, 12:27 PM
#6
Lively Member
my bad the code i posted above should be this
Code:
private sub command1_click
dim item as string
item = combo1.text
combo2.additem item
end sub
this code would be used with a command button but you could change it to whatever you wanted.
-
Mar 11th, 2004, 01:04 PM
#7
Or :
VB Code:
Private Sub Combo1_Click()
Combo2.AddItem Combo1.List(Combo1.ListIndex)
End Sub
Has someone helped you? Then you can Rate their helpful post. 
-
Mar 11th, 2004, 01:10 PM
#8
OK, now I really think I see what you want.
VB Code:
Private Sub Combo1_Click()
Combo2.AddItem Combo1.List(Combo1.ListIndex)
End Sub
-
Mar 11th, 2004, 03:41 PM
#9
Supreme User
VB Code:
Private Sub Form_Load()
Combo1.AddItem = Hello
Combo1.AddItem -Goodbye
End Sub
Private Sub Combo1_Click()
Select Case Combo1.Text
Case "Hello"
MsgBox ("Hello")
Case "Goodbye"
MsgBox ("Goodbye")
End Select
End Sub
-
Mar 11th, 2004, 03:53 PM
#10
Originally posted by Madboy
VB Code:
Private Sub Form_Load()
Combo1.AddItem = Hello
Combo1.AddItem -Goodbye
End Sub
Private Sub Combo1_Click()
Select Case Combo1.Text
Case "Hello"
MsgBox ("Hello")
Case "Goodbye"
MsgBox ("Goodbye")
End Select
End Sub
What's with the = and - ? They aren't needed... They are wrong
Has someone helped you? Then you can Rate their helpful post. 
-
Mar 11th, 2004, 04:41 PM
#11
Supreme User
- was a mistake, and i couldnt remember the syntax off the top of my head regarding the =.
The general Select Case code is a nice clean working example, he can remove my errors now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|