如何在ComboBox的每个项目上添加一个数值并将其显示到VB.NET中的TextBox?
我尝试使用此代码:
Dim value As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.combobox1.Items.Add("Single")
Me.combobox1.Items.Add("Double")
End sub
Private Sub Roomtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If combobox1.SelectedIndex = 0 Then
value = Val(1000)
ElseIf combobox1.SelectedIndex = 1 Then
value = Val(2000)
End sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
txtTotal.Text = Val(value) * Val(textbox1.Text)
End sub
例如,我选择项目“ single”,然后将其值乘以2,我希望txtTotal.text
中的输出为2000,但没有输出。