easy question on combo box
-
I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan
-
I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan
why can't you use Request.form("id of combobox").value it returns index of number selected by user when he leaves the form use document.all("idofcombobox").value in javascript for same value without post back form
-
why can't you use Request.form("id of combobox").value it returns index of number selected by user when he leaves the form use document.all("idofcombobox").value in javascript for same value without post back form
Visual Basic doesn't understand "Request" and since I've never used it, neither do I. While I'm still in the form, I have the combo box. It is called NumSamp. It seems to me that I ought to be able to query NumSamp in some easy way to find out which value in a list of values was chosen. In fact, NumSamp.SelectedIndex() gives me the correct offset in the list of values. I'm just missing the next step: given the index, what is the value of the entry? Thanks, Ilan
-
I've got what should be an easy question, but I can't find the correct combination in VB.NET. I have a drop down list of numbers in a combo box. When I leave the form, I want to know which number was chosen. NumSamp.SelectedIndex() tells me which index I've chosen, but I can't get the integer or text value of the entry. NumSamp.SelectedText() or NumSamp.SelectedValue() both come back as nothing. There must be an easy way to get the value of the chosen entry, but I can't seem to find it. Thanks, Ilan
Use
NumSamp.SelectedItem
. If you're coding with Option Strict On use the.ToString()
method as well. SamplePrivate Sub Button1_Click(...) Handles Button1.Click
'pass value of selected item to Form2
Dim frm2 As New Form2
frm2.Text = Me.ComboBox1.SelectedItem.ToString
frm2.Show()
End Sub -
Use
NumSamp.SelectedItem
. If you're coding with Option Strict On use the.ToString()
method as well. SamplePrivate Sub Button1_Click(...) Handles Button1.Click
'pass value of selected item to Form2
Dim frm2 As New Form2
frm2.Text = Me.ComboBox1.SelectedItem.ToString
frm2.Show()
End Sub -
Visual Basic doesn't understand "Request" and since I've never used it, neither do I. While I'm still in the form, I have the combo box. It is called NumSamp. It seems to me that I ought to be able to query NumSamp in some easy way to find out which value in a list of values was chosen. In fact, NumSamp.SelectedIndex() gives me the correct offset in the list of values. I'm just missing the next step: given the index, what is the value of the entry? Thanks, Ilan
NumSamp.SelectedIndex.value will solve your problem
-
NumSamp.SelectedIndex.value will solve your problem