I'm working on a coffee shop project for my teacher that has 3 different forms and a module I thought I was done when she told me to. Declare an "AddToOrder" sub procedure to keep a running subtotal of regular and/or decaf coffee ordered. I then started to decipher what that means I think I have the codes to do it but their in the wrong spots if anyone could just look at what I have and tell me what I need to do that be helpful. I declared the ADD TO ORDER sub procedure in my module. I don't know what goes in it but the purpose of it to keep track of the amount of coffee bought. You see I have a 2 different forms with 2 different list boxes to order coffee from that display messages on how much coffee you bought by selecting from the decaf or regular list boxes. This is what I have so far I'm not asking you to do my homework at all I just need to know what has to go into my AddToOrder sub procedure. Any help I'd appreciate it.

Module Module2
    Public intFirst As Integer = 10
    Public intSecond As Integer = 18
    Public intThird As Integer = 85
    Public intOne As Integer = 8
    Public intTwo As Integer = 15
    Public intTen As Integer = 70
    Public Const dblTAXRATE As Double = 0.07
    Public g_Total As Double
    Public Function CalcTax(ByVal cost As Decimal) As Double
        ' This function calculates and returns the
        ' sales tax on ticket sales. The ticket cost is
        ' passed as an argument.
        Return cost * dblTAXRATE
    End Function
    Public Sub AddToOrder()
        g_Total += intFirst
        g_Total += intSecond
        g_Total += intThird
        g_Total += intOne
        g_Total += intTwo
        g_Total += intTen
    End Sub
End Module
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        'Adds pounds together

        If lstSize.SelectedIndex = -1 Then
            MsgBox("Select a Size", MsgBoxStyle.Critical)
        Else

        Select Case CStr(lstSize.SelectedIndex)
                Case CStr(0)
                    g_Total += intOne * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(1)
                    g_Total += intTwo * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(2)
                    g_Total += intTen * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
            End Select
        End If
    End Sub
Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click
        'Retains the price of the coffee you order
      

        If lstPounds.SelectedIndex = -1 Then
            MsgBox("Select a Size", MsgBoxStyle.Critical)
        Else
            Select Case CStr(lstPounds.SelectedIndex)
                Case CStr(0)
                    g_Total += intFirst * nudQuantity.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(1)
                    g_Total += intSecond * nudQuantity.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(2)
                    g_Total += intThird * nudQuantity.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & g_Total, "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
            End Select
        End If
    End Sub

You could declare a variable to hold the subtotal for decaf coffee and another variable to hold the subtotal for your regular coffee subtotal in your module. Next, declare a grand total variable that will hold the total for decaf and regular coffee. Accumulate the decaf coffee subtotal and regular coffee subtotal into grand total in your AddToOrder subroutine. Change the grand total variable to the appropriate decaf or regular subtotal variables in your two forms. Be sure to call your AddToOrder module after your case structures and reset the decaf and regular coffee subtotals to 0.

Module Module2
    Public intFirst As Integer = 10
    Public intSecond As Integer = 18
    Public intThird As Integer = 85
    Public intOne As Integer = 8
    Public intTwo As Integer = 15
    Public intTen As Integer = 70
    Public Const dblTAXRATE As Double = 0.07
    Public regular_Total  as double ‘Regular Coffee Subtotal
    Public decaf_Total  as double ‘Decaf coffee total
    Public g_Total As Double ‘Grand total
    Public Function CalcTax(ByVal cost As Decimal) As Double
        ' This function calculates and returns the
        ' sales tax on ticket sales. The ticket cost is
        ' passed as an argument.
        Return cost * dblTAXRATE
    End Function
    Public Sub AddToOrder()
        g_Total += decaf_Total + regular_Total
    End Sub
End Module
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        'Adds pounds together

        If lstSize.SelectedIndex = -1 Then
            MsgBox("Select a Size", MsgBoxStyle.Critical)
        Else

        Select Case CStr(lstSize.SelectedIndex)
                Case CStr(0)
        decaf_Total  = intOne * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & decaf_Total  , "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(1)
        decaf_Total  = intTwo * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & decaf_Total  , "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(2)
                    decaf_Total  = intTen * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & decaf_Total  , "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
            End Select

          Call AddToOrder()

          decaf_Total  = 0

        End If
 
    End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        'Adds pounds together

        If lstSize.SelectedIndex = -1 Then
            MsgBox("Select a Size", MsgBoxStyle.Critical)
        Else

        Select Case CStr(lstSize.SelectedIndex)
                Case CStr(0)
        regular_Total = intOne * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & regular_Total , "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(1)
        regular_Total  = intTwo * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & regular_Total,   "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
                Case CStr(2)
                    regular_Total  = intTen * nudOrder.Value
                    MessageBox.Show(CStr("Current SubTotal is $") & regular_Total , "SubTotal", MessageBoxButtons.OK, MessageBoxIcon.Question)
            End Select
        End If

       Call AddToOrder()

       regular_Total  = 0

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.