I am a student in school and I'm trying to figure out why my saleSummaryForm is not being popluated with the information needed. Could someone clue me into what I am missing or what I did wrong? I know that there may be more code in what I am posting below then needs to be there, but it is there so that you can see what I have already tried and am afraid to delete until I can figure out what I am doing right and wrong.

below is the summary code in the project.

Private Sub summaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles summaryButton.Click
        Dim indexInteger As Integer
        Dim totalTicketSalesDecimal As Decimal
        Dim seatsSoldInteger As Integer
        Dim costDecimal As Decimal
        Dim returnDialogResult As System.Windows.Forms.DialogResult

        seatsSoldInteger = ticketDetail(indexInteger).seatsSoldInteger
        costDecimal = ticketDetail(indexInteger).costDecimal

        
        For ticketDetail As Integer = 0 To 3
            indexInteger = 0
            totalTicketSalesDecimal = seatsSoldInteger * costDecimal

        Next ticketDetail

        SalesSummaryForm.balconyTotalSeatsTextBox.Text = ticketDetail(0).seatsSoldInteger
        SalesSummaryForm.generaltotalSeatsTextBox.Text = ticketDetail(1).seatsSoldInteger
        SalesSummaryForm.mezzanineTotalSeatsTextBox.Text = ticketDetail(2).seatsSoldInteger
        SalesSummaryForm.orchestraTotalSeatsTextBox.Text = ticketDetail(3).seatsSoldInteger
        SalesSummaryForm.balconyTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.generalTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.mezzanineTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.orchestraTotalSalesTextBox.Text = totalTicketSalesDecimal

        returnDialogResult = SalesSummaryForm.ShowDialog()

        If returnDialogResult = System.Windows.Forms.DialogResult.Yes Then
            SalesSummaryForm.balconyTotalSeatsTextBox.Clear()
            SalesSummaryForm.generaltotalSeatsTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSeatsTextBox.Clear()
            SalesSummaryForm.orchestraTotalSeatsTextBox.Clear()
            SalesSummaryForm.balconyTotalSalesTextBox.Clear()
            SalesSummaryForm.generalTotalSalesTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSalesTextBox.Clear()
            SalesSummaryForm.orchestraTotalSalesTextBox.Clear()
            Me.summaryButton.Enabled = False

        End If


    End Sub

Thought it may be better to post the whole project in a zip file for you to look at.

Please do not make changes to it, just clue me into the direction I need to go. This is causing me a headache, but I know it right in front of me and I am not seeing the solution.

Private Sub acceptButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles acceptButton.Click, acceptButton.Click

        Dim numSeatsInteger As Integer
        Dim indexInteger As Integer

        ticketDetail(indexInteger).seatsSoldInteger += numSeatsInteger

        Me.numSeatsTextBox.Clear()
        Me.ticketCostTextBox.Clear()
        Me.sectionComboBox.Text = Nothing

        Me.summaryButton.Enabled = True

    End Sub

you are not setting the integer in the red line to anything.
it just remains zero

try maybe

ticketDetail(indexInteger).seatsSoldInteger += numSeatsTextBox.text

hope that helps ..

the above will throw Conversion from string "" to type 'Double' is not valid.

cdbl() maybe not sure. hopefully you can figure it out from that point if not let me know
im going home for the day tho.

good luck

Found that that line was in the wrong block of code and moved it to the block.

having problem with the calculations for the summary form so that the cast will be correct and in the right places.

Private Sub summaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles summaryButton.Click
        Dim indexInteger As Integer
        Dim totalTicketSalesDecimal As Decimal
        Dim seatsSoldInteger As Integer
        Dim costDecimal As Decimal
        Dim returnDialogResult As System.Windows.Forms.DialogResult

        For countInteger As Integer = 0 To 3

            seatsSoldInteger = ticketDetail(indexInteger).seatsSoldInteger
            costDecimal = ticketDetail(indexInteger).costDecimal

            totalTicketSalesDecimal = seatsSoldInteger * costDecimal

        Next countInteger


        SalesSummaryForm.balconyTotalSeatsTextBox.Text = ticketDetail(0).seatsSoldInteger
        SalesSummaryForm.generaltotalSeatsTextBox.Text = ticketDetail(1).seatsSoldInteger
        SalesSummaryForm.mezzanineTotalSeatsTextBox.Text = ticketDetail(2).seatsSoldInteger
        SalesSummaryForm.orchestraTotalSeatsTextBox.Text = ticketDetail(3).seatsSoldInteger
        SalesSummaryForm.balconyTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.generalTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.mezzanineTotalSalesTextBox.Text = totalTicketSalesDecimal
        SalesSummaryForm.orchestraTotalSalesTextBox.Text = totalTicketSalesDecimal

        'SalesSummaryForm.overAllSalesTextBox.Text = totalTicketSalesDecimal(+totalTicketSalesDecimal)


        returnDialogResult = SalesSummaryForm.ShowDialog()

        If returnDialogResult = System.Windows.Forms.DialogResult.Yes Then
            SalesSummaryForm.balconyTotalSeatsTextBox.Clear()
            SalesSummaryForm.generaltotalSeatsTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSeatsTextBox.Clear()
            SalesSummaryForm.orchestraTotalSeatsTextBox.Clear()
            SalesSummaryForm.balconyTotalSalesTextBox.Clear()
            SalesSummaryForm.generalTotalSalesTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSalesTextBox.Clear()
            SalesSummaryForm.orchestraTotalSalesTextBox.Clear()
            Me.summaryButton.Enabled = False

        End If


    End Sub
Option Strict On
Option Explicit On

Public Class TicketSalesForm

    'Structure and module level variable
    Structure TicketSales

        Dim sectionString As String
        Dim seatsSoldInteger As Integer
        Dim costDecimal As Decimal

    End Structure

    Private ticketDetail(3) As TicketSales
    Private indexinteger As Integer



    Private Sub TicketsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ticketDetail(0).sectionString = "Balcony"
        ticketDetail(1).sectionString = "General"
        ticketDetail(2).sectionString = "Mezzanine"
        ticketDetail(3).sectionString = "Orchestra"
        ticketDetail(0).costDecimal = 10D
        ticketDetail(1).costDecimal = 15D
        ticketDetail(2).costDecimal = 27.5D
        ticketDetail(3).costDecimal = 40D
    End Sub

    Private Sub acceptButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles acceptButton.Click, acceptButton.Click

        ticketDetail(indexinteger).seatsSoldInteger += CInt(Val(Me.numSeatsTextBox.Text))


        Me.numSeatsTextBox.Clear()
        Me.ticketCostTextBox.Clear()


        Me.summaryButton.Enabled = True
    End Sub

    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Application.Exit()
    End Sub

    Private Sub summaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles summaryButton.Click
        On Error Resume Next

        Dim totalticketsalesdecimal As Double = 0

        Dim returnDialogResult As System.Windows.Forms.DialogResult

        SalesSummaryForm.balconyTotalSeatsTextBox.Text = ticketDetail(0).seatsSoldInteger.ToString
        SalesSummaryForm.generaltotalSeatsTextBox.Text = ticketDetail(1).seatsSoldInteger.ToString
        SalesSummaryForm.mezzanineTotalSeatsTextBox.Text = ticketDetail(2).seatsSoldInteger.ToString
        SalesSummaryForm.orchestraTotalSeatsTextBox.Text = ticketDetail(3).seatsSoldInteger.ToString
        SalesSummaryForm.balconyTotalSalesTextBox.Text = FormatCurrency(ticketDetail(0).costDecimal.ToString, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.generalTotalSalesTextBox.Text = FormatCurrency(ticketDetail(1).costDecimal.ToString, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.mezzanineTotalSalesTextBox.Text = FormatCurrency(ticketDetail(2).costDecimal.ToString, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.orchestraTotalSalesTextBox.Text = FormatCurrency(ticketDetail(3).costDecimal.ToString, 2, TriState.False, TriState.False, TriState.False)

        totalticketsalesdecimal = ticketDetail(0).costDecimal + ticketDetail(1).costDecimal + ticketDetail(2).costDecimal + ticketDetail(3).costDecimal

        SalesSummaryForm.overAllSalesTextBox.Text = FormatCurrency(totalticketsalesdecimal.ToString, 2, TriState.False, TriState.False, TriState.False)




        returnDialogResult = SalesSummaryForm.ShowDialog()

        If returnDialogResult = System.Windows.Forms.DialogResult.Yes Then
            SalesSummaryForm.balconyTotalSeatsTextBox.Clear()
            SalesSummaryForm.generaltotalSeatsTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSeatsTextBox.Clear()
            SalesSummaryForm.orchestraTotalSeatsTextBox.Clear()
            SalesSummaryForm.balconyTotalSalesTextBox.Clear()
            SalesSummaryForm.generalTotalSalesTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSalesTextBox.Clear()
            SalesSummaryForm.orchestraTotalSalesTextBox.Clear()
            Me.summaryButton.Enabled = False

        End If


    End Sub

    Private Sub calculationButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculationButton.Click
        Dim numSeatsInteger As Integer = 0
        Dim salesTotalDecimal As Decimal

        numSeatsInteger = CInt(Me.numSeatsTextBox.Text)

        salesTotalDecimal = ticketDetail(indexinteger).costDecimal * numSeatsInteger
        Me.ticketCostTextBox.Text = salesTotalDecimal.ToString
    End Sub

    Private Sub sectionComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sectionComboBox.SelectedIndexChanged
        Me.indexinteger = Me.sectionComboBox.SelectedIndex
    End Sub
End Class

that works. your going to just have to go through it and see what i did i didnt do a great job on commenting it sorry. if you have a question about what i did just ask

Edited 5 Years Ago by jlego: actually i didnt comment it at all

sorry nevermind i wasnt paying attention to the costs. it is just leaving them at whatever your section pricing is set at. ill look at it again

HERE IS THE WORKING VERSION WITH THE CORRECT COST:

Option Strict On
Option Explicit On

Public Class TicketSalesForm

    'Structure and module level variable
    Structure TicketSales

        Dim sectionString As String
        Dim seatsSoldInteger As Integer
        Dim costDecimal As Decimal

    End Structure

    Private ticketDetail(3) As TicketSales
    Private indexinteger As Integer



    Private Sub TicketsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ticketDetail(0).sectionString = "Balcony"
        ticketDetail(1).sectionString = "General"
        ticketDetail(2).sectionString = "Mezzanine"
        ticketDetail(3).sectionString = "Orchestra"
        ticketDetail(0).costDecimal = 10D
        ticketDetail(1).costDecimal = 15D
        ticketDetail(2).costDecimal = 27.5D
        ticketDetail(3).costDecimal = 40D
    End Sub

    Private Sub acceptButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles acceptButton.Click, acceptButton.Click

        ticketDetail(indexinteger).seatsSoldInteger += CInt(Val(Me.numSeatsTextBox.Text))


        Me.numSeatsTextBox.Clear()
        Me.ticketCostTextBox.Clear()


        Me.summaryButton.Enabled = True
    End Sub

    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Application.Exit()
    End Sub

    Private Sub summaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles summaryButton.Click
        On Error Resume Next

        Dim totalticketsalesdecimal As Double = 0
        Dim i As Integer = 0

        Dim returnDialogResult As System.Windows.Forms.DialogResult

        Do While i <= 3
            totalticketsalesdecimal = totalticketsalesdecimal + ticketDetail(i).seatsSoldInteger * ticketDetail(i).costDecimal
            i = i + 1
        Loop

        SalesSummaryForm.balconyTotalSeatsTextBox.Text = ticketDetail(0).seatsSoldInteger.ToString
        SalesSummaryForm.generaltotalSeatsTextBox.Text = ticketDetail(1).seatsSoldInteger.ToString
        SalesSummaryForm.mezzanineTotalSeatsTextBox.Text = ticketDetail(2).seatsSoldInteger.ToString
        SalesSummaryForm.orchestraTotalSeatsTextBox.Text = ticketDetail(3).seatsSoldInteger.ToString
        SalesSummaryForm.balconyTotalSalesTextBox.Text = FormatCurrency(ticketDetail(0).seatsSoldInteger * ticketDetail(0).costDecimal, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.generalTotalSalesTextBox.Text = FormatCurrency(ticketDetail(1).seatsSoldInteger * ticketDetail(1).costDecimal, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.mezzanineTotalSalesTextBox.Text = FormatCurrency(ticketDetail(2).seatsSoldInteger * ticketDetail(2).costDecimal, 2, TriState.False, TriState.False, TriState.False)
        SalesSummaryForm.orchestraTotalSalesTextBox.Text = FormatCurrency(ticketDetail(3).seatsSoldInteger * ticketDetail(3).costDecimal, 2, TriState.False, TriState.False, TriState.False)


        SalesSummaryForm.overAllSalesTextBox.Text = FormatCurrency(totalticketsalesdecimal, 2, TriState.False, TriState.False, TriState.False)




        returnDialogResult = SalesSummaryForm.ShowDialog()

        If returnDialogResult = System.Windows.Forms.DialogResult.Yes Then
            SalesSummaryForm.balconyTotalSeatsTextBox.Clear()
            SalesSummaryForm.generaltotalSeatsTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSeatsTextBox.Clear()
            SalesSummaryForm.orchestraTotalSeatsTextBox.Clear()
            SalesSummaryForm.balconyTotalSalesTextBox.Clear()
            SalesSummaryForm.generalTotalSalesTextBox.Clear()
            SalesSummaryForm.mezzanineTotalSalesTextBox.Clear()
            SalesSummaryForm.orchestraTotalSalesTextBox.Clear()
            Me.summaryButton.Enabled = False

        End If


    End Sub

    Private Sub calculationButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculationButton.Click
        Dim numSeatsInteger As Integer = 0
        Dim salesTotalDecimal As Decimal

        numSeatsInteger = CInt(Me.numSeatsTextBox.Text)

        salesTotalDecimal = ticketDetail(indexinteger).costDecimal * numSeatsInteger
        Me.ticketCostTextBox.Text = salesTotalDecimal.ToString
    End Sub

    Private Sub sectionComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sectionComboBox.SelectedIndexChanged
        Me.indexinteger = Me.sectionComboBox.SelectedIndex
    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.