Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim subtot As Decimal
- Dim total1 As Decimal
- Dim total2 As Decimal
- Dim total3 As Decimal
- Dim tot As Decimal
- Dim totz As Decimal
- Dim quantz As Decimal
- Dim quantztot As Decimal
- Dim pricez As Decimal
- Dim taxtot As Decimal
- Const taxz As Decimal = 0.08D
- Const capp As Decimal = 2D
- Const espress As Decimal = 2.25D
- Const latte As Decimal = 1.75D
- Const iced As Decimal = 2.5D
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.Text = "Reading and Refreshment"
- Label1.Text = "&Quantity"
- Label2.Text = "Item Amount"
- Label3.Text = "Sub Total"
- Label4.Text = "Tax (Takeout)"
- Label5.Text = "Total Due"
- Button1.Text = "&Calculate Selection"
- Button2.Text = "C&lear for Next Item"
- Button3.Text = "&New Order"
- Button4.Text = "&Summary"
- Button5.Text = "E&xit"
- RadioButton1.Text = "C&appuccino"
- RadioButton2.Text = "Espress&o"
- RadioButton3.Text = "La&tte"
- RadioButton4.Text = "&Iced Latte"
- RadioButton5.Text = "Iced Ca&ppuccino"
- GroupBox1.Text = "Order Information"
- GroupBox2.Text = "Coffee Selections"
- GroupBox3.Text = "Totals"
- CheckBox1.Checked = True
- CheckBox1.Enabled = False
- CheckBox1.Text = "Taxes"
- CheckBox2.Checked = False
- CheckBox2.Text = "Ta&keout?"
- End Sub
- Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
- If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
- e.Handled = True
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim price, tax As Decimal
- Dim quant As Integer
- If RadioButton1.Checked = False And RadioButton2.Checked = False And _
- RadioButton3.Checked = False And RadioButton4.Checked = False And _
- RadioButton5.Checked = False Then
- MsgBox("You must make a selection from the list of available items.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Coffee Error")
- Exit Sub
- End If
- quant = Val(TextBox1.Text)
- If RadioButton1.Checked Then
- price = capp * quant
- tax = price * taxz
- price = price + tax
- tot = pricez + price
- If CheckBox1.Checked = True Then
- tax = price * taxz
- price = price + tax
- taxtot = taxtot + tax
- TextBox4.Text = tax.ToString("C")
- End If
- If CheckBox2.Checked = True Then
- price = price + 2
- End If
- total1 = quantz + quant
- total2 = price + subtot
- total3 = price + subtot + tax
- TextBox2.Text = total1.ToString("C")
- TextBox3.Text = total2.ToString("C")
- TextBox5.Text = total3.ToString("C")
- ElseIf RadioButton2.Checked Then
- price = espress * quant
- tax = price * taxz
- price = price + tax
- tot = pricez + price
- If CheckBox1.Checked = True Then
- tax = price * taxz
- price = price + tax
- taxtot = taxtot + tax
- TextBox4.Text = tax.ToString("C")
- End If
- total1 = quantz + quant
- total2 = price + subtot
- total3 = price + subtot + tax
- TextBox2.Text = total1.ToString("C")
- TextBox3.Text = total2.ToString("C")
- TextBox5.Text = total3.ToString("C")
- ElseIf RadioButton3.Checked Then
- price = latte * quant
- tax = price * taxz
- price = price + tax
- tot = pricez + price
- If CheckBox1.Checked = True Then
- tax = price * taxz
- price = price + tax
- taxtot = taxtot + tax
- TextBox4.Text = tax.ToString("C")
- End If
- total1 = quantz + quant
- total2 = price + subtot
- total3 = price + subtot + tax
- TextBox2.Text = total1.ToString("C")
- TextBox3.Text = total2.ToString("C")
- TextBox5.Text = total3.ToString("C")
- ElseIf RadioButton4.Checked Or RadioButton5.Checked Then
- tax = price * taxz
- price = price + tax
- price = iced * quant
- tot = pricez + price
- If CheckBox1.Checked = True Then
- tax = price * taxz
- price = price + tax
- TextBox4.Text = tax.ToString("C")
- taxtot = taxtot + tax
- End If
- total1 = quantz + quant
- total2 = price + subtot
- total3 = price + subtot + tax
- TextBox2.Text = total1.ToString("C")
- TextBox3.Text = total2.ToString("C")
- TextBox5.Text = total3.ToString("C")
- End If
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- TextBox1.Text = ""
- TextBox3.Text = ""
- TextBox4.Text = ""
- TextBox5.Text = ""
- quantztot = quantztot + 1
- totz = totz + tot
- TextBox1.Focus()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- TextBox1.Text = ""
- TextBox2.Text = ""
- RadioButton1.Checked = False
- RadioButton2.Checked = False
- RadioButton3.Checked = False
- RadioButton4.Checked = False
- RadioButton5.Checked = False
- CheckBox2.Checked = False
- TextBox1.Focus()
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- End
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- If quantztot = 0 Then
- MsgBox("No data to summarize.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Coffee Error")
- Exit Sub
- End If
- MsgBox("Total orders: " & quantztot & vbNewLine & "Total amount taxed: $" & FormatNumber(taxtot, 2) & vbNewLine & "Total amount due: $" & FormatNumber(totz, 2), MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Coffee Summary")
- End Sub
Add Comment
Please, Sign In to add comment