Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7793763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:35:24+00:00 2026-06-01T22:35:24+00:00

Hiim fairly new to vb so i hope i explain this right, the problem

  • 0

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…

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.

My code is below:

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

Any help what so ever, wld be a great help.. iv been at this for hours.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:35:26+00:00Added an answer on June 1, 2026 at 10:35 pm

    This part of your code is problematic:

    If (ComboBox1.SelectedIndex And ComboBox2.SelectedIndex And ComboBox3.SelectedIndex And ComboBox4.SelectedIndex) = -1 Then
    

    Using And in this manner doesn’t give the result you probably expect. It performs a bitwise And operation on the SelectedIndexValues. If you want to check if all selected indexes have a value of -1, you should do it like this:

    If ComboBox1.SelectedIndex = -1 And ComboBox2.SelectedIndex = -1 And ComboBox3.SelectedIndex = -1 And ComboBox4.SelectedIndex = -1 Then
    

    It would also be a good idea to use AndAlso instead of And.

    Also, there’s no reason to use a Try-Catch clause in your code. Just show the message box inside the If statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi im new to jquery and im facing these problem i have these code
hi im really new to actionscript and ive have a problem with playing sound.
Hi im working through the Creating a store locator tutorial on google that can
Hi im new to iphone development by searching i found that iphone development can
hi im fairly new to cms made simple and ive stumbled upon a problem
Hi im fairly new to this im trying to use image urls as sources
hi im new to c# and was trying to code but getting error can
Hi im having a problem to figure this out, i am literally going nuts.
Hi im trying to merge two tables. I have ids that exists only in
hi im new to android i have added defined login screen in one screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.