Sorry for the confusing thread title but im trying to make a fast food program on which the user will input the amount that he has, then he will check on what he wants, by using check boxes. There are 7 different check boxes with 7 different amounts of money. I have the program somewhat finished (thanks for the people that helped me before) but theres still a couple of things that I still need to get finished but I dont know how to.
I need to be able to get how much money the user has (this will be entered threw a text box, I think I accidentally messed this part up, because I cant get it to work right, (theres alreasy a permit amount of money in there and it needs to be what the user enters instead of the permit, 5.59, one) and this will be the maximum amount he can spend, then the user will check on the food he wants (and the program will add the sales tax also) then it will produce an answer saying if you have enough money or if you dont. But what im confused on is how do I get the users amount of money and make it the maximum mount he can spend and make sure it doesnt go over the amount that he has checked. Thats basically all I need to finish, but I dont know how to, can someone help me out? This is what code I have.

Public Class Form1
    '// Prices for the CheckBoxes as Decimal Arrays.
    Private myCoolCheckBoxPrices() As Double = {3.99, 2.79, 3.29, 1.39, 1.59, 1.99, 2.56}
    Private myCustomerTotalSpendingAllowed As Double = 5.59 '// Total a Customer has set for Spending Limit. 5.59 should not be there, but for now its the only way the program can run

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                    Handles _
                                      Hamsandwich.CheckedChanged, hamburger.CheckedChanged, lettucewrap.CheckedChanged, _
                                      sodapopsmall.CheckedChanged, sodapoplarge.CheckedChanged, fries.CheckedChanged, sidesalad.CheckedChanged
        Dim myTotalPrice As Double = 0 '// Reset Total Price.
        '// If CheckBox is Checked, add the Decimal Array to myTotalPrice.
        If Hamsandwich.Checked Then myTotalPrice += myCoolCheckBoxPrices(0)
        If hamburger.Checked Then myTotalPrice += myCoolCheckBoxPrices(1)
        If lettucewrap.Checked Then myTotalPrice += myCoolCheckBoxPrices(2)
        If sodapopsmall.Checked Then myTotalPrice += myCoolCheckBoxPrices(3)
        If sodapoplarge.Checked Then myTotalPrice += myCoolCheckBoxPrices(4)
        If fries.Checked Then myTotalPrice += myCoolCheckBoxPrices(5)
        If sidesalad.Checked Then myTotalPrice += myCoolCheckBoxPrices(6)
        Me.Text = myTotalPrice.ToString("c") '// Display result.
        '//----- compare TotalPrice with the price the customer has set for spending limit.
        If myTotalPrice > myCustomerTotalSpendingAllowed Then '// if price goes over, alert customer with the amount over the set limit.
            MsgBox("Total price has went over your customer's spending limit." _
            & vbNewLine & "Amount over the limit: " & (myCustomerTotalSpendingAllowed - myTotalPrice).ToString("c"), MsgBoxStyle.Critical)
        End If '-----\\
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
End Class
6 Years
Discussion Span
Last Post by codeorder

Use the _TextChanged event and set the value as it is being typed in.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        '// check if numeric, then set new value for myCustomerTotalSpendingAllowed.
        If IsNumeric(TextBox1.Text) Then myCustomerTotalSpendingAllowed = CDbl(TextBox1.Text)
    End Sub
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.