Hiim相當新的VB,所以我希望我解釋這個權利, 我的問題是,即時創建一個劇院預訂系統,我似乎無法得到提交按鈕來打開下一個窗體沒有組合框做一樣。 我有四個組合框和一個提交按鈕都鏈接到同一個事件。這是用戶可以選擇票數,總數將自動顯示在總標籤中,當提交按鈕被按下一個新表格時,Form3將出現...當沒有錯誤出現時該怎麼辦?
我需要至少一個組合必須選擇方框,否則會出現一個錯誤,提示「請至少選擇一個選票」,然後如果在按下提交按鈕時至少選擇了一個,則應顯示下一個表格,但使用代碼下拉框被選中它打開一個新的表格,我知道我的問題..但我不知道如何得到我想要的。
我的代碼如下:
Sub ComboBoxes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged, ComboBox2.SelectedIndexChanged, ComboBox3.SelectedIndexChanged, ComboBox4.SelectedIndexChanged, Submitbtn.Click
'Assigned an evet handler to all of the comboboxes then calculates the price and puts in total box
Dim Totalcombo1, Totalcombo2, Totalcombo3, Totalcombo4, Price As Decimal
Dim valuecombo1 = (ComboBox1.SelectedIndex + 1) 'finds position of option selected & adds one to get number of tickets
Dim valuecombo2 = (ComboBox2.SelectedIndex + 1)
Dim valuecombo3 = (ComboBox3.SelectedIndex + 1)
Dim valuecombo4 = (ComboBox4.SelectedIndex + 1)
'if the submit button is selected without there being a value selected from any combobox then error should appear, saying at least 1 ticket should be purchased.
If (ComboBox2.SelectedIndex = -1) Then
Totalcombo2 = 0
Else
Price = 6.5
Totalcombo2 = valuecombo2 * Price
End If
'determines the ticketprice of combobox 1
If (ComboBox1.SelectedIndex = -1) Then
Totalcombo1 = 0
Else
Price = 9
Totalcombo1 = valuecombo1 * Price
End If
'determines the ticketprice of combobox 2
If (ComboBox3.SelectedIndex = -1) Then
Totalcombo3 = 0
Else
Price = 6.5
Totalcombo3 = valuecombo3 * Price
End If
'determines the ticketprice of combobox 3
If (ComboBox4.SelectedIndex = -1) Then
Totalcombo4 = 0
Else
Price = 6.5
Totalcombo4 = valuecombo4 * Price
End If
'determines the ticketprice of combobox 4
Try
If (ComboBox1.SelectedIndex And ComboBox2.SelectedIndex And ComboBox3.SelectedIndex And ComboBox4.SelectedIndex) = -1 Then
Throw New System.Exception()
End If
Catch ex As Exception When (ComboBox1.SelectedIndex And ComboBox2.SelectedIndex And ComboBox3.SelectedIndex And ComboBox4.SelectedIndex) = -1
MessageBox.Show("Please make at least one ticket selection before continuing. ")
End Try
Totallbl.Text = Totalcombo1 + Totalcombo2 + Totalcombo3 + Totalcombo4
'adds the totals of the ticketprices and then inserts into the Total label
End Sub
Sub SubmitForm_OpenBooking()
Dim FrmBooking As New Form3
FrmBooking.Show()
Me.Hide()
End Sub
任何幫助什麼那麼,WLD是一個很大的幫助.. IV已經在好幾個小時了。
Metro?的WinForms? WPF? Silverlight的? ASP.Net? MonoTouch的? – SLaks 2012-04-11 20:43:42
我猜想它的代碼的WinForms。 – nikhil 2012-04-11 20:46:14
是啊,即時通訊使用visual basic窗體 – MightyMouse 2012-04-11 22:28:48