Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat to do when there is no error present?
    primarykey
    data
    text
    <p>Hiim fairly new to vb so i hope i explain this right, the problem I have is that im creating a theatre booking system and i can't seem to get the Submit button to open the next form without the combo boxes doing the same thing. I have four combo boxes and a submit button all linked to the same event. This is so the user can select the number of tickets, the total will display automatically in the total label and when the submit button is pressed a new form, Form3 will appear...</p> <p>I need at least one of the combo boxes has to be selected or an error will appear saying "please make at lease one ticket selection", then if at least one has been selected when the submit button is pressed the next form should appear, but with the code i have when a drop down box is selected it opens a new form, I know my problem.. but i dont know how to get what i want.</p> <p>My code is below:</p> <pre><code>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 &amp; 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 </code></pre> <p>Any help what so ever, wld be a great help.. iv been at this for hours.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload