Guest User

Untitled

a guest
Sep 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. Public Class Form1
  2. Dim subtot As Decimal
  3. Dim total1 As Decimal
  4. Dim total2 As Decimal
  5. Dim total3 As Decimal
  6. Dim tot As Decimal
  7. Dim totz As Decimal
  8. Dim quantz As Decimal
  9. Dim quantztot As Decimal
  10. Dim pricez As Decimal
  11. Dim taxtot As Decimal
  12. Const taxz As Decimal = 0.08D
  13. Const capp As Decimal = 2D
  14. Const espress As Decimal = 2.25D
  15. Const latte As Decimal = 1.75D
  16. Const iced As Decimal = 2.5D
  17.  
  18. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  19. Me.Text = "Reading and Refreshment"
  20. Label1.Text = "&Quantity"
  21. Label2.Text = "Item Amount"
  22. Label3.Text = "Sub Total"
  23. Label4.Text = "Tax (Takeout)"
  24. Label5.Text = "Total Due"
  25. Button1.Text = "&Calculate Selection"
  26. Button2.Text = "C&lear for Next Item"
  27. Button3.Text = "&New Order"
  28. Button4.Text = "&Summary"
  29. Button5.Text = "E&xit"
  30. RadioButton1.Text = "C&appuccino"
  31. RadioButton2.Text = "Espress&o"
  32. RadioButton3.Text = "La&tte"
  33. RadioButton4.Text = "&Iced Latte"
  34. RadioButton5.Text = "Iced Ca&ppuccino"
  35. GroupBox1.Text = "Order Information"
  36. GroupBox2.Text = "Coffee Selections"
  37. GroupBox3.Text = "Totals"
  38. CheckBox1.Checked = True
  39. CheckBox1.Enabled = False
  40. CheckBox1.Text = "Taxes"
  41. CheckBox2.Checked = False
  42. CheckBox2.Text = "Ta&keout?"
  43. End Sub
  44.  
  45. Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  46. If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
  47. e.Handled = True
  48. End If
  49. End Sub
  50.  
  51.  
  52. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  53. Dim price, tax As Decimal
  54. Dim quant As Integer
  55.  
  56. If RadioButton1.Checked = False And RadioButton2.Checked = False And _
  57. RadioButton3.Checked = False And RadioButton4.Checked = False And _
  58. RadioButton5.Checked = False Then
  59. MsgBox("You must make a selection from the list of available items.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Coffee Error")
  60. Exit Sub
  61. End If
  62.  
  63. quant = Val(TextBox1.Text)
  64. If RadioButton1.Checked Then
  65. price = capp * quant
  66. tax = price * taxz
  67. price = price + tax
  68. tot = pricez + price
  69. If CheckBox1.Checked = True Then
  70. tax = price * taxz
  71. price = price + tax
  72. taxtot = taxtot + tax
  73. TextBox4.Text = tax.ToString("C")
  74. End If
  75. If CheckBox2.Checked = True Then
  76. price = price + 2
  77. End If
  78. total1 = quantz + quant
  79. total2 = price + subtot
  80. total3 = price + subtot + tax
  81. TextBox2.Text = total1.ToString("C")
  82. TextBox3.Text = total2.ToString("C")
  83. TextBox5.Text = total3.ToString("C")
  84. ElseIf RadioButton2.Checked Then
  85. price = espress * quant
  86. tax = price * taxz
  87. price = price + tax
  88. tot = pricez + price
  89. If CheckBox1.Checked = True Then
  90. tax = price * taxz
  91. price = price + tax
  92. taxtot = taxtot + tax
  93. TextBox4.Text = tax.ToString("C")
  94. End If
  95. total1 = quantz + quant
  96. total2 = price + subtot
  97. total3 = price + subtot + tax
  98. TextBox2.Text = total1.ToString("C")
  99. TextBox3.Text = total2.ToString("C")
  100. TextBox5.Text = total3.ToString("C")
  101. ElseIf RadioButton3.Checked Then
  102. price = latte * quant
  103. tax = price * taxz
  104. price = price + tax
  105. tot = pricez + price
  106. If CheckBox1.Checked = True Then
  107. tax = price * taxz
  108. price = price + tax
  109. taxtot = taxtot + tax
  110. TextBox4.Text = tax.ToString("C")
  111. End If
  112. total1 = quantz + quant
  113. total2 = price + subtot
  114. total3 = price + subtot + tax
  115. TextBox2.Text = total1.ToString("C")
  116. TextBox3.Text = total2.ToString("C")
  117. TextBox5.Text = total3.ToString("C")
  118. ElseIf RadioButton4.Checked Or RadioButton5.Checked Then
  119. tax = price * taxz
  120. price = price + tax
  121. price = iced * quant
  122. tot = pricez + price
  123. If CheckBox1.Checked = True Then
  124. tax = price * taxz
  125. price = price + tax
  126. TextBox4.Text = tax.ToString("C")
  127. taxtot = taxtot + tax
  128. End If
  129. total1 = quantz + quant
  130. total2 = price + subtot
  131. total3 = price + subtot + tax
  132. TextBox2.Text = total1.ToString("C")
  133. TextBox3.Text = total2.ToString("C")
  134. TextBox5.Text = total3.ToString("C")
  135. End If
  136. End Sub
  137.  
  138. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  139. TextBox1.Text = ""
  140. TextBox3.Text = ""
  141. TextBox4.Text = ""
  142. TextBox5.Text = ""
  143. quantztot = quantztot + 1
  144. totz = totz + tot
  145. TextBox1.Focus()
  146. End Sub
  147.  
  148. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  149. TextBox1.Text = ""
  150. TextBox2.Text = ""
  151. RadioButton1.Checked = False
  152. RadioButton2.Checked = False
  153. RadioButton3.Checked = False
  154. RadioButton4.Checked = False
  155. RadioButton5.Checked = False
  156. CheckBox2.Checked = False
  157. TextBox1.Focus()
  158. End Sub
  159.  
  160. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  161. End
  162. End Sub
  163.  
  164. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  165. If quantztot = 0 Then
  166. MsgBox("No data to summarize.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Coffee Error")
  167. Exit Sub
  168. End If
  169. 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")
  170. End Sub
Add Comment
Please, Sign In to add comment