0

Hey, all!
I am running into trouble with some code I am doing for an assignment.
The section highlighted in red is the section that I am having trouble with.
When the user selects a seat type and then clicks the compute button,
the wrong cost is displayed instead of an accurate cost.

Is there any way I can fix this issue?

Option Strict On
Public Class frmTickets

    Private Sub btnComputeCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComputeCost.Click
        Dim intNumberOfTickets As Integer
        Dim decTotalCost As Decimal
        Dim decBoxSeats As Decimal = 2500D
        Dim decLowerDeck As Decimal = 1500D
        Dim decBoxSeats2 As Decimal = 55D
        Dim decLowerDeck2 As Decimal = 35D
        Dim decUpperDeck As Decimal = 25D
        Dim decStandingRoomOnly As Decimal = 15D

        intNumberOfTickets = Convert.ToInt32(Me.txtTicketNumber.Text)

        If Me.cboTicketType.SelectedIndex = 0 Then
            If Me.lstSeatType.SelectedIndex = 0 Then
                decTotalCost = decBoxSeats * intNumberOfTickets
            Else
                decTotalCost = decLowerDeck * intNumberOfTickets
            End If
        End If

        If Me.cboTicketType.SelectedIndex = 1 Then
            If Me.lstSeatType.SelectedIndex = 1 Then
                decTotalCost = decBoxSeats2 * intNumberOfTickets
            Else
                decTotalCost = decLowerDeck2 * intNumberOfTickets
            End If
        Else
            If Me.cboTicketType.SelectedIndex = 1 Then
                If Me.lstSeatType.SelectedIndex = 1 Then
                    decTotalCost = decUpperDeck * intNumberOfTickets
                Else
                    decTotalCost = decStandingRoomOnly * intNumberOfTickets
                End If
            End If
        End If

        Me.lblTotalCost.Text = "The total cost of tickets purchased: " & decTotalCost.ToString("C")
        Me.lblTotalCost.Visible = True
    End Sub

    Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
        Dim intTicketType As Integer

        intTicketType = Me.cboTicketType.SelectedIndex
        Select Case intTicketType
            Case 0
                Me.lstSeatType.Items.Add("Box Seats $2500")
                Me.lstSeatType.Items.Add("Lower Deck $1500")
            Case 1
                Me.lstSeatType.Items.Add("Box Seats $55")
                Me.lstSeatType.Items.Add("Lower Deck $35")
                Me.lstSeatType.Items.Add("Upper Deck $25")
                Me.lstSeatType.Items.Add("Standing Room Only $15")
        End Select

        Me.lblTicketNumber.Visible = True
        Me.txtTicketNumber.Visible = True
        Me.lblSeatType.Visible = True
        Me.lstSeatType.Visible = True
        Me.btnComputeCost.Visible = True
        Me.btnClearForm.Visible = True
    End Sub
End Class
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by lolafuertes
0

If Me.cboTicketType.SelectedIndex = 1 Then
.
.
.
Else
If Me.cboTicketType.SelectedIndex = 1 Then
. It is impossible to get into this
End If
End If

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.