combobox array help

Page 1 of 1

1 Replies - 143 Views - Last Post: 29 November 2013 - 02:22 PM Rate Topic: -----

#1 glb482417  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 28-November 13

combobox array help

Posted 29 November 2013 - 02:17 PM

I am making a pizza order form i have to combo boxes SizeCombobox has small,medium,large,monster you can select, combobox 2 has regular, stuffed crust you can select witch ones you click determines the price that gets sent to the textbox ihave coded it but it sends 0.00 to the textbox can someone help me. Lines 2 thru 10, lines 51 thru 81, and lines 150 thru 157 is the array code i need help with trying to send the prices to the pizzatextbox

Public Class MamaJanesForm
    'Declare structure and module-level variables.

    Structure Pizza
        Dim RegularDecimal As Decimal
        Dim StuffedDecimal As Decimal
    End Structure

    'Hold pizza number and total for 5 pizza styles.
    Private PizzaGroup(4) As Pizza
    ' Declare a named constant.
    Const Peppers_Charge_Decimal As Decimal = 0.75D
    Const Onions_Charge_Decimal As Decimal = 0.75D
    Const ExtraCheese_Charge_Decimal As Decimal = 0.75D
    Const Coupon_Rate_Decimal As Decimal = 0.1D
    Const PreferredCustomer_Rate_Decimal As Decimal = 0.15D
    Const SalesTax_Rate_Decimal As Decimal = 0.08D
    Dim ToppingsDecimal, DiscountDecimal, PizzaDecimal, SalestaxDecimal As Decimal


    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        ' Change the font name for the label.
        With FontDialog1
            .ShowDialog()
            AmountDueLabel.Font = .Font
        End With
    End Sub

    Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
        ' Change the color of the amount due label.
        With ColorDialog1
            .ShowDialog()
            AmountDueLabel.ForeColor = .Color
        End With
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        Dim MessageString As String
        ' Display the message box.
        MessageString = "Mama Jane's Pizza" & Environment.NewLine & "Programmed by Gary Brewster"
        MessageBox.Show(MessageString, "About Mama Jane's Pizza", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        ' Terminate the program.
        Me.Close()
    End Sub

    Private Sub CalculateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateToolStripMenuItem.Click
        Dim ToppingsDecimal, DiscountDecimal, PizzaDecimal, SalestaxDecimal, AmountDueDecimal As Decimal
        'Allows the user to seach for either the size and style.

        'Declare local variables
        Dim IndexInteger As Integer = 0
        Dim FoundBoolean As Boolean = False

        'Look up pizza to find subscript.
        Do Until FoundBoolean Or IndexInteger > 4
            If PizzaDecimal = PizzaGroup(IndexInteger).RegularDecimal Then
                'If found set boolean to true, and display the abbreviation.
                FoundBoolean = True
                PizzaDecimal = PizzaGroup(IndexInteger).StuffedDecimal

            Else
                'If not found continue the search
                IndexInteger += 1
                'Nested if statement to find the state name.
                If PizzaDecimal = PizzaGroup(IndexInteger).StuffedDecimal Then
                    'If found set boolean to true, and display the state name.
                    FoundBoolean = True
                    PizzaDecimal = PizzaGroup(IndexInteger).RegularDecimal

                Else
                    'If not found continue the search
                End If
            End If
        Loop
        If Not FoundBoolean Then
            MessageBox.Show("Must enter a valid pizza type", "Invalid Input", _
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If
        'Include the Toppings charges.
        If CheckBox1.Checked Then
            ToppingsDecimal += Peppers_Charge_Decimal
        End If
        If CheckBox2.Checked Then
            ToppingsDecimal += Onions_Charge_Decimal
        End If
        If CheckBox3.Checked Then
            ToppingsDecimal += ExtraCheese_Charge_Decimal
        End If
        ' In clude the discount       
        If RadioButton2.Checked = True Then

            DiscountDecimal = Coupon_Rate_Decimal * (PizzaDecimal + ToppingsDecimal)
        ElseIf RadioButton3.Checked = True Then

            DiscountDecimal = PreferredCustomer_Rate_Decimal * (PizzaDecimal + ToppingsDecimal)
        End If
        ' Calculate sales tax.
        If RadioButton1.Checked = True Then
            SalestaxDecimal = SalesTax_Rate_Decimal * (PizzaDecimal + ToppingsDecimal - DiscountDecimal)
        ElseIf RadioButton2.Checked = True Then
            SalestaxDecimal = SalesTax_Rate_Decimal * (PizzaDecimal + ToppingsDecimal - DiscountDecimal)
        ElseIf RadioButton3.Checked = True Then
            SalestaxDecimal = (ToppingsDecimal + PizzaDecimal - DiscountDecimal) * SalesTax_Rate_Decimal
        End If
        ' Find the total.
        If SalestaxDecimal >= 0 Then
            AmountDueDecimal = (ToppingsDecimal + PizzaDecimal + SalestaxDecimal - DiscountDecimal)

        End If
        'Display amounts in labels
        ToppingsTextBox.Text = ToppingsDecimal.ToString("C")
        DiscountTextBox.Text = DiscountDecimal.ToString("C")
        SalesTaxTextBox.Text = SalestaxDecimal.ToString("C")
        PizzaTextBox.Text = PizzaDecimal.ToString("C")
        AmountDueTextBox.Text = AmountDueDecimal.ToString("C")

    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
        ' Clear all information.
        NameTextBox.Clear()
        AddressTextBox.Clear()
        CityTextBox.Clear()
        StateTextBox.Clear()
        zipTextBox.Clear()
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        RadioButton1.Checked = False
        RadioButton2.Checked = False
        RadioButton3.Checked = False
        SizeComboBox.SelectedIndex = -1
        StyleComboBox.SelectedIndex = -1
        PizzaTextBox.Clear()
        ToppingsTextBox.Clear()
        DiscountTextBox.Clear()
        SalesTaxTextBox.Clear()
        AmountDueTextBox.Clear()
        RadioButton1.Focus()
        NameTextBox.Focus()
    End Sub


    Private Sub MamaJanesForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Initialize state names and abbreviations

        PizzaGroup(0).RegularDecimal = "5.99"
        PizzaGroup(0).StuffedDecimal = "6.99"
        PizzaGroup(1).RegularDecimal = "6.99"
        PizzaGroup(1).StuffedDecimal = "7.99"
        PizzaGroup(2).RegularDecimal = "7.99"
        PizzaGroup(2).StuffedDecimal = "8.99"
        PizzaGroup(3).RegularDecimal = "8.99"
        PizzaGroup(3).StuffedDecimal = "9.99"
    End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: combobox array help

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: combobox array help

Posted 29 November 2013 - 02:22 PM

Duplicate thread closed. Do not open multiple threads for the same question. - Posting it in the wrong forum won't help either.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1