Combo box value?
-
Thursday, March 06, 2008 8:30 PM
I'm trying to assign to value of a combo box (value member) to a variable in vb. Unfortunately, my experience has been with Off97 and I'm having a problem with this simple task in the Express Edition (VB).
All Replies
-
Thursday, March 06, 2008 8:43 PMCode Snippet
comboBox1.Items.Add("test")
comboBox1.Items.Add("test1")
comboBox1.SelectedIndex = 0
MessageBox.Show(comboBox1.SelectedItem.ToString())
-
Thursday, March 06, 2008 9:54 PM
Thanks for your help crock. While your suggestion is useful, it doesn't directly address what I was asking. I guess I wasn't very clear. Let me re-phrase it.
I have a combo box already populated. I want to assign the value of a selected item from the combo box to a variable in vb. Here two examples taken from CBF in one of my Access 97 apps.
Dim CHtRef as String, OpAcGrp as Single
CHTRef = Me!cmbLevel1.Column(4)
OpACGrp = Me!tcmbLevel2
-
Sunday, March 09, 2008 9:27 AM
They are a few ways to get the data
Dim
MyVal As String1) MyVal = ComboBox1.SelectedItem
2) MyVal = ComboBox1.SelectedText
3) MyVal = ComboBox1.SelectedValue
4) MyVal = ComboBox1.Items().Item(ComboBox1.SelectedIndex)


