Guest User

Untitled

a guest
Jan 4th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.40 KB | None | 0 0
  1. ' project comments go here
  2.  
  3.  
  4. Option Strict On
  5. Option Explicit On
  6.  
  7. Public Class frmBooksale
  8. Inherits System.Windows.Forms.Form
  9.  
  10. #Region "Windows Form Designer generated code "
  11. Public Sub New()
  12. MyBase.New()
  13. 'This call is required by the Windows Form Designer.
  14. InitializeComponent()
  15. End Sub
  16. 'Form overrides dispose to clean up the component list.
  17. Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
  18. If Disposing Then
  19. If Not components Is Nothing Then
  20. components.Dispose()
  21. End If
  22. End If
  23. MyBase.Dispose(Disposing)
  24. End Sub
  25. Private components As System.ComponentModel.IContainer
  26. 'Required by the Windows Form Designer
  27. Public ToolTip1 As System.Windows.Forms.ToolTip
  28. Public WithEvents lblAverageDiscount As System.Windows.Forms.Label
  29. Public WithEvents Label11 As System.Windows.Forms.Label
  30. Public WithEvents lblDiscountedAmountSum As System.Windows.Forms.Label
  31. Public WithEvents lblDiscountSum As System.Windows.Forms.Label
  32. Public WithEvents lblQuantitySum As System.Windows.Forms.Label
  33. Public WithEvents Label10 As System.Windows.Forms.Label
  34. Public WithEvents Label9 As System.Windows.Forms.Label
  35. Public WithEvents Label8 As System.Windows.Forms.Label
  36. Public WithEvents lblDiscountedPrice As System.Windows.Forms.Label
  37. Public WithEvents lblDiscount As System.Windows.Forms.Label
  38. Public WithEvents lblExtendedPrice As System.Windows.Forms.Label
  39. Public WithEvents Label7 As System.Windows.Forms.Label
  40. Public WithEvents Label6 As System.Windows.Forms.Label
  41. Public WithEvents Label5 As System.Windows.Forms.Label
  42. Public WithEvents txtPrice As System.Windows.Forms.TextBox
  43. Public WithEvents txtTitle As System.Windows.Forms.TextBox
  44. Public WithEvents txtQuantity As System.Windows.Forms.TextBox
  45. Public WithEvents Label4 As System.Windows.Forms.Label
  46. Public WithEvents Label3 As System.Windows.Forms.Label
  47. Public WithEvents Label2 As System.Windows.Forms.Label
  48. Public WithEvents btnClear As System.Windows.Forms.Button
  49. Public WithEvents btnExit As System.Windows.Forms.Button
  50. Public WithEvents btnCalculate As System.Windows.Forms.Button
  51. Public WithEvents grpSummary As System.Windows.Forms.GroupBox
  52. Public WithEvents grpOutput As System.Windows.Forms.GroupBox
  53. Public WithEvents grpInpt As System.Windows.Forms.GroupBox
  54. Public WithEvents Label1 As System.Windows.Forms.Label
  55. 'NOTE: The following procedure is required by the Windows Form Designer
  56. 'It can be modified using the Windows Form Designer.
  57. 'Do not modify it using the code editor.
  58. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  59. Me.components = New System.ComponentModel.Container()
  60. Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
  61. Me.btnClear = New System.Windows.Forms.Button()
  62. Me.txtTitle = New System.Windows.Forms.TextBox()
  63. Me.txtPrice = New System.Windows.Forms.TextBox()
  64. Me.btnExit = New System.Windows.Forms.Button()
  65. Me.btnCalculate = New System.Windows.Forms.Button()
  66. Me.grpInpt = New System.Windows.Forms.GroupBox()
  67. Me.txtQuantity = New System.Windows.Forms.TextBox()
  68. Me.Label4 = New System.Windows.Forms.Label()
  69. Me.Label3 = New System.Windows.Forms.Label()
  70. Me.Label2 = New System.Windows.Forms.Label()
  71. Me.grpSummary = New System.Windows.Forms.GroupBox()
  72. Me.lblAverageDiscount = New System.Windows.Forms.Label()
  73. Me.Label11 = New System.Windows.Forms.Label()
  74. Me.lblDiscountedAmountSum = New System.Windows.Forms.Label()
  75. Me.lblDiscountSum = New System.Windows.Forms.Label()
  76. Me.lblQuantitySum = New System.Windows.Forms.Label()
  77. Me.Label10 = New System.Windows.Forms.Label()
  78. Me.Label9 = New System.Windows.Forms.Label()
  79. Me.Label8 = New System.Windows.Forms.Label()
  80. Me.grpOutput = New System.Windows.Forms.GroupBox()
  81. Me.lblDiscountedPrice = New System.Windows.Forms.Label()
  82. Me.lblDiscount = New System.Windows.Forms.Label()
  83. Me.lblExtendedPrice = New System.Windows.Forms.Label()
  84. Me.Label7 = New System.Windows.Forms.Label()
  85. Me.Label6 = New System.Windows.Forms.Label()
  86. Me.Label5 = New System.Windows.Forms.Label()
  87. Me.Label1 = New System.Windows.Forms.Label()
  88. Me.grpInpt.SuspendLayout()
  89. Me.grpSummary.SuspendLayout()
  90. Me.grpOutput.SuspendLayout()
  91. Me.SuspendLayout()
  92. '
  93. 'btnClear
  94. '
  95. Me.btnClear.BackColor = System.Drawing.SystemColors.Control
  96. Me.btnClear.Cursor = System.Windows.Forms.Cursors.Default
  97. Me.btnClear.DialogResult = System.Windows.Forms.DialogResult.Cancel
  98. Me.btnClear.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  99. Me.btnClear.Location = New System.Drawing.Point(139, 440)
  100. Me.btnClear.Name = "btnClear"
  101. Me.btnClear.RightToLeft = System.Windows.Forms.RightToLeft.No
  102. Me.btnClear.Size = New System.Drawing.Size(94, 38)
  103. Me.btnClear.TabIndex = 17
  104. Me.btnClear.Text = "C&lear Sale"
  105. Me.ToolTip1.SetToolTip(Me.btnClear, "Clear the input text boxes for the current sale.")
  106. Me.btnClear.UseVisualStyleBackColor = False
  107. '
  108. 'txtTitle
  109. '
  110. Me.txtTitle.AcceptsReturn = True
  111. Me.txtTitle.BackColor = System.Drawing.SystemColors.Window
  112. Me.txtTitle.Cursor = System.Windows.Forms.Cursors.IBeam
  113. Me.txtTitle.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  114. Me.txtTitle.ForeColor = System.Drawing.SystemColors.WindowText
  115. Me.txtTitle.Location = New System.Drawing.Point(84, 46)
  116. Me.txtTitle.MaxLength = 0
  117. Me.txtTitle.Name = "txtTitle"
  118. Me.txtTitle.RightToLeft = System.Windows.Forms.RightToLeft.No
  119. Me.txtTitle.Size = New System.Drawing.Size(188, 23)
  120. Me.txtTitle.TabIndex = 4
  121. Me.ToolTip1.SetToolTip(Me.txtTitle, "Title of book sold")
  122. '
  123. 'txtPrice
  124. '
  125. Me.txtPrice.AcceptsReturn = True
  126. Me.txtPrice.BackColor = System.Drawing.SystemColors.Window
  127. Me.txtPrice.Cursor = System.Windows.Forms.Cursors.IBeam
  128. Me.txtPrice.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  129. Me.txtPrice.ForeColor = System.Drawing.SystemColors.WindowText
  130. Me.txtPrice.Location = New System.Drawing.Point(84, 74)
  131. Me.txtPrice.MaxLength = 0
  132. Me.txtPrice.Name = "txtPrice"
  133. Me.txtPrice.RightToLeft = System.Windows.Forms.RightToLeft.No
  134. Me.txtPrice.Size = New System.Drawing.Size(76, 23)
  135. Me.txtPrice.TabIndex = 6
  136. Me.ToolTip1.SetToolTip(Me.txtPrice, "Price of one book")
  137. '
  138. 'btnExit
  139. '
  140. Me.btnExit.BackColor = System.Drawing.SystemColors.Control
  141. Me.btnExit.Cursor = System.Windows.Forms.Cursors.Default
  142. Me.btnExit.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  143. Me.btnExit.Location = New System.Drawing.Point(248, 440)
  144. Me.btnExit.Name = "btnExit"
  145. Me.btnExit.RightToLeft = System.Windows.Forms.RightToLeft.No
  146. Me.btnExit.Size = New System.Drawing.Size(85, 38)
  147. Me.btnExit.TabIndex = 16
  148. Me.btnExit.Text = "E&xit"
  149. Me.ToolTip1.SetToolTip(Me.btnExit, "Exit the program")
  150. Me.btnExit.UseVisualStyleBackColor = False
  151. '
  152. 'btnCalculate
  153. '
  154. Me.btnCalculate.BackColor = System.Drawing.SystemColors.Control
  155. Me.btnCalculate.Cursor = System.Windows.Forms.Cursors.Default
  156. Me.btnCalculate.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  157. Me.btnCalculate.Location = New System.Drawing.Point(29, 440)
  158. Me.btnCalculate.Name = "btnCalculate"
  159. Me.btnCalculate.RightToLeft = System.Windows.Forms.RightToLeft.No
  160. Me.btnCalculate.Size = New System.Drawing.Size(94, 38)
  161. Me.btnCalculate.TabIndex = 15
  162. Me.btnCalculate.Text = "&Calculate"
  163. Me.ToolTip1.SetToolTip(Me.btnCalculate, "Calculate this sale and add to summary totals")
  164. Me.btnCalculate.UseVisualStyleBackColor = False
  165. '
  166. 'grpInpt
  167. '
  168. Me.grpInpt.BackColor = System.Drawing.SystemColors.Control
  169. Me.grpInpt.Controls.Add(Me.txtPrice)
  170. Me.grpInpt.Controls.Add(Me.txtTitle)
  171. Me.grpInpt.Controls.Add(Me.txtQuantity)
  172. Me.grpInpt.Controls.Add(Me.Label4)
  173. Me.grpInpt.Controls.Add(Me.Label3)
  174. Me.grpInpt.Controls.Add(Me.Label2)
  175. Me.grpInpt.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  176. Me.grpInpt.ForeColor = System.Drawing.SystemColors.ControlText
  177. Me.grpInpt.Location = New System.Drawing.Point(28, 46)
  178. Me.grpInpt.Name = "grpInpt"
  179. Me.grpInpt.RightToLeft = System.Windows.Forms.RightToLeft.No
  180. Me.grpInpt.Size = New System.Drawing.Size(422, 112)
  181. Me.grpInpt.TabIndex = 7
  182. Me.grpInpt.TabStop = False
  183. Me.ToolTip1.SetToolTip(Me.grpInpt, "Input sale information for the sale of a book")
  184. '
  185. 'txtQuantity
  186. '
  187. Me.txtQuantity.AcceptsReturn = True
  188. Me.txtQuantity.BackColor = System.Drawing.SystemColors.Window
  189. Me.txtQuantity.Cursor = System.Windows.Forms.Cursors.IBeam
  190. Me.txtQuantity.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  191. Me.txtQuantity.ForeColor = System.Drawing.SystemColors.WindowText
  192. Me.txtQuantity.Location = New System.Drawing.Point(84, 19)
  193. Me.txtQuantity.MaxLength = 0
  194. Me.txtQuantity.Name = "txtQuantity"
  195. Me.txtQuantity.RightToLeft = System.Windows.Forms.RightToLeft.No
  196. Me.txtQuantity.Size = New System.Drawing.Size(67, 23)
  197. Me.txtQuantity.TabIndex = 2
  198. Me.ToolTip1.SetToolTip(Me.txtQuantity, "Quantity sold as a whole number")
  199. '
  200. 'Label4
  201. '
  202. Me.Label4.BackColor = System.Drawing.SystemColors.Control
  203. Me.Label4.Cursor = System.Windows.Forms.Cursors.Default
  204. Me.Label4.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  205. Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
  206. Me.Label4.Location = New System.Drawing.Point(18, 74)
  207. Me.Label4.Name = "Label4"
  208. Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
  209. Me.Label4.Size = New System.Drawing.Size(49, 20)
  210. Me.Label4.TabIndex = 5
  211. Me.Label4.Text = "&Price"
  212. '
  213. 'Label3
  214. '
  215. Me.Label3.BackColor = System.Drawing.SystemColors.Control
  216. Me.Label3.Cursor = System.Windows.Forms.Cursors.Default
  217. Me.Label3.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  218. Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
  219. Me.Label3.Location = New System.Drawing.Point(18, 46)
  220. Me.Label3.Name = "Label3"
  221. Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
  222. Me.Label3.Size = New System.Drawing.Size(49, 20)
  223. Me.Label3.TabIndex = 3
  224. Me.Label3.Text = "&Title"
  225. '
  226. 'Label2
  227. '
  228. Me.Label2.BackColor = System.Drawing.SystemColors.Control
  229. Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
  230. Me.Label2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  231. Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
  232. Me.Label2.Location = New System.Drawing.Point(18, 19)
  233. Me.Label2.Name = "Label2"
  234. Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
  235. Me.Label2.Size = New System.Drawing.Size(58, 19)
  236. Me.Label2.TabIndex = 1
  237. Me.Label2.Text = "&Quantity"
  238. '
  239. 'grpSummary
  240. '
  241. Me.grpSummary.BackColor = System.Drawing.SystemColors.Control
  242. Me.grpSummary.Controls.Add(Me.lblAverageDiscount)
  243. Me.grpSummary.Controls.Add(Me.Label11)
  244. Me.grpSummary.Controls.Add(Me.lblDiscountedAmountSum)
  245. Me.grpSummary.Controls.Add(Me.lblDiscountSum)
  246. Me.grpSummary.Controls.Add(Me.lblQuantitySum)
  247. Me.grpSummary.Controls.Add(Me.Label10)
  248. Me.grpSummary.Controls.Add(Me.Label9)
  249. Me.grpSummary.Controls.Add(Me.Label8)
  250. Me.grpSummary.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  251. Me.grpSummary.ForeColor = System.Drawing.SystemColors.ControlText
  252. Me.grpSummary.Location = New System.Drawing.Point(28, 287)
  253. Me.grpSummary.Name = "grpSummary"
  254. Me.grpSummary.RightToLeft = System.Windows.Forms.RightToLeft.No
  255. Me.grpSummary.Size = New System.Drawing.Size(425, 140)
  256. Me.grpSummary.TabIndex = 18
  257. Me.grpSummary.TabStop = False
  258. Me.grpSummary.Text = "Summary"
  259. Me.ToolTip1.SetToolTip(Me.grpSummary, "Summary for all sales entered in a single run of the program")
  260. '
  261. 'lblAverageDiscount
  262. '
  263. Me.lblAverageDiscount.BackColor = System.Drawing.SystemColors.Control
  264. Me.lblAverageDiscount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  265. Me.lblAverageDiscount.Cursor = System.Windows.Forms.Cursors.Default
  266. Me.lblAverageDiscount.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  267. Me.lblAverageDiscount.ForeColor = System.Drawing.SystemColors.ControlText
  268. Me.lblAverageDiscount.Location = New System.Drawing.Point(290, 102)
  269. Me.lblAverageDiscount.Name = "lblAverageDiscount"
  270. Me.lblAverageDiscount.RightToLeft = System.Windows.Forms.RightToLeft.No
  271. Me.lblAverageDiscount.Size = New System.Drawing.Size(104, 19)
  272. Me.lblAverageDiscount.TabIndex = 26
  273. Me.lblAverageDiscount.TextAlign = System.Drawing.ContentAlignment.TopRight
  274. '
  275. 'Label11
  276. '
  277. Me.Label11.BackColor = System.Drawing.SystemColors.Control
  278. Me.Label11.Cursor = System.Windows.Forms.Cursors.Default
  279. Me.Label11.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  280. Me.Label11.ForeColor = System.Drawing.SystemColors.ControlText
  281. Me.Label11.Location = New System.Drawing.Point(124, 102)
  282. Me.Label11.Name = "Label11"
  283. Me.Label11.RightToLeft = System.Windows.Forms.RightToLeft.No
  284. Me.Label11.Size = New System.Drawing.Size(151, 19)
  285. Me.Label11.TabIndex = 25
  286. Me.Label11.Text = "Average Discount"
  287. '
  288. 'lblDiscountedAmountSum
  289. '
  290. Me.lblDiscountedAmountSum.BackColor = System.Drawing.SystemColors.Control
  291. Me.lblDiscountedAmountSum.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  292. Me.lblDiscountedAmountSum.Cursor = System.Windows.Forms.Cursors.Default
  293. Me.lblDiscountedAmountSum.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  294. Me.lblDiscountedAmountSum.ForeColor = System.Drawing.SystemColors.ControlText
  295. Me.lblDiscountedAmountSum.Location = New System.Drawing.Point(290, 74)
  296. Me.lblDiscountedAmountSum.Name = "lblDiscountedAmountSum"
  297. Me.lblDiscountedAmountSum.RightToLeft = System.Windows.Forms.RightToLeft.No
  298. Me.lblDiscountedAmountSum.Size = New System.Drawing.Size(104, 20)
  299. Me.lblDiscountedAmountSum.TabIndex = 24
  300. Me.lblDiscountedAmountSum.TextAlign = System.Drawing.ContentAlignment.TopRight
  301. '
  302. 'lblDiscountSum
  303. '
  304. Me.lblDiscountSum.BackColor = System.Drawing.SystemColors.Control
  305. Me.lblDiscountSum.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  306. Me.lblDiscountSum.Cursor = System.Windows.Forms.Cursors.Default
  307. Me.lblDiscountSum.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  308. Me.lblDiscountSum.ForeColor = System.Drawing.SystemColors.ControlText
  309. Me.lblDiscountSum.Location = New System.Drawing.Point(290, 46)
  310. Me.lblDiscountSum.Name = "lblDiscountSum"
  311. Me.lblDiscountSum.RightToLeft = System.Windows.Forms.RightToLeft.No
  312. Me.lblDiscountSum.Size = New System.Drawing.Size(104, 20)
  313. Me.lblDiscountSum.TabIndex = 23
  314. Me.lblDiscountSum.TextAlign = System.Drawing.ContentAlignment.TopRight
  315. '
  316. 'lblQuantitySum
  317. '
  318. Me.lblQuantitySum.BackColor = System.Drawing.SystemColors.Control
  319. Me.lblQuantitySum.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  320. Me.lblQuantitySum.Cursor = System.Windows.Forms.Cursors.Default
  321. Me.lblQuantitySum.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  322. Me.lblQuantitySum.ForeColor = System.Drawing.SystemColors.ControlText
  323. Me.lblQuantitySum.Location = New System.Drawing.Point(290, 19)
  324. Me.lblQuantitySum.Name = "lblQuantitySum"
  325. Me.lblQuantitySum.RightToLeft = System.Windows.Forms.RightToLeft.No
  326. Me.lblQuantitySum.Size = New System.Drawing.Size(104, 19)
  327. Me.lblQuantitySum.TabIndex = 22
  328. Me.lblQuantitySum.TextAlign = System.Drawing.ContentAlignment.TopRight
  329. '
  330. 'Label10
  331. '
  332. Me.Label10.BackColor = System.Drawing.SystemColors.Control
  333. Me.Label10.Cursor = System.Windows.Forms.Cursors.Default
  334. Me.Label10.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  335. Me.Label10.ForeColor = System.Drawing.SystemColors.ControlText
  336. Me.Label10.Location = New System.Drawing.Point(124, 74)
  337. Me.Label10.Name = "Label10"
  338. Me.Label10.RightToLeft = System.Windows.Forms.RightToLeft.No
  339. Me.Label10.Size = New System.Drawing.Size(151, 20)
  340. Me.Label10.TabIndex = 21
  341. Me.Label10.Text = "Total Discounted Amounts"
  342. '
  343. 'Label9
  344. '
  345. Me.Label9.BackColor = System.Drawing.SystemColors.Control
  346. Me.Label9.Cursor = System.Windows.Forms.Cursors.Default
  347. Me.Label9.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  348. Me.Label9.ForeColor = System.Drawing.SystemColors.ControlText
  349. Me.Label9.Location = New System.Drawing.Point(124, 46)
  350. Me.Label9.Name = "Label9"
  351. Me.Label9.RightToLeft = System.Windows.Forms.RightToLeft.No
  352. Me.Label9.Size = New System.Drawing.Size(151, 20)
  353. Me.Label9.TabIndex = 20
  354. Me.Label9.Text = "Total Discounts Given"
  355. '
  356. 'Label8
  357. '
  358. Me.Label8.BackColor = System.Drawing.SystemColors.Control
  359. Me.Label8.Cursor = System.Windows.Forms.Cursors.Default
  360. Me.Label8.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  361. Me.Label8.ForeColor = System.Drawing.SystemColors.ControlText
  362. Me.Label8.Location = New System.Drawing.Point(124, 19)
  363. Me.Label8.Name = "Label8"
  364. Me.Label8.RightToLeft = System.Windows.Forms.RightToLeft.No
  365. Me.Label8.Size = New System.Drawing.Size(151, 19)
  366. Me.Label8.TabIndex = 19
  367. Me.Label8.Text = "Total Number of Books"
  368. '
  369. 'grpOutput
  370. '
  371. Me.grpOutput.BackColor = System.Drawing.SystemColors.Control
  372. Me.grpOutput.Controls.Add(Me.lblDiscountedPrice)
  373. Me.grpOutput.Controls.Add(Me.lblDiscount)
  374. Me.grpOutput.Controls.Add(Me.lblExtendedPrice)
  375. Me.grpOutput.Controls.Add(Me.Label7)
  376. Me.grpOutput.Controls.Add(Me.Label6)
  377. Me.grpOutput.Controls.Add(Me.Label5)
  378. Me.grpOutput.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  379. Me.grpOutput.ForeColor = System.Drawing.SystemColors.ControlText
  380. Me.grpOutput.Location = New System.Drawing.Point(28, 167)
  381. Me.grpOutput.Name = "grpOutput"
  382. Me.grpOutput.RightToLeft = System.Windows.Forms.RightToLeft.No
  383. Me.grpOutput.Size = New System.Drawing.Size(422, 103)
  384. Me.grpOutput.TabIndex = 8
  385. Me.grpOutput.TabStop = False
  386. Me.ToolTip1.SetToolTip(Me.grpOutput, "Information for a single sale")
  387. '
  388. 'lblDiscountedPrice
  389. '
  390. Me.lblDiscountedPrice.BackColor = System.Drawing.SystemColors.Control
  391. Me.lblDiscountedPrice.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  392. Me.lblDiscountedPrice.Cursor = System.Windows.Forms.Cursors.Default
  393. Me.lblDiscountedPrice.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  394. Me.lblDiscountedPrice.ForeColor = System.Drawing.SystemColors.ControlText
  395. Me.lblDiscountedPrice.Location = New System.Drawing.Point(290, 74)
  396. Me.lblDiscountedPrice.Name = "lblDiscountedPrice"
  397. Me.lblDiscountedPrice.RightToLeft = System.Windows.Forms.RightToLeft.No
  398. Me.lblDiscountedPrice.Size = New System.Drawing.Size(104, 20)
  399. Me.lblDiscountedPrice.TabIndex = 14
  400. Me.lblDiscountedPrice.TextAlign = System.Drawing.ContentAlignment.TopRight
  401. '
  402. 'lblDiscount
  403. '
  404. Me.lblDiscount.BackColor = System.Drawing.SystemColors.Control
  405. Me.lblDiscount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  406. Me.lblDiscount.Cursor = System.Windows.Forms.Cursors.Default
  407. Me.lblDiscount.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  408. Me.lblDiscount.ForeColor = System.Drawing.SystemColors.ControlText
  409. Me.lblDiscount.Location = New System.Drawing.Point(290, 46)
  410. Me.lblDiscount.Name = "lblDiscount"
  411. Me.lblDiscount.RightToLeft = System.Windows.Forms.RightToLeft.No
  412. Me.lblDiscount.Size = New System.Drawing.Size(104, 20)
  413. Me.lblDiscount.TabIndex = 12
  414. Me.lblDiscount.TextAlign = System.Drawing.ContentAlignment.TopRight
  415. '
  416. 'lblExtendedPrice
  417. '
  418. Me.lblExtendedPrice.BackColor = System.Drawing.SystemColors.Control
  419. Me.lblExtendedPrice.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
  420. Me.lblExtendedPrice.Cursor = System.Windows.Forms.Cursors.Default
  421. Me.lblExtendedPrice.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  422. Me.lblExtendedPrice.ForeColor = System.Drawing.SystemColors.ControlText
  423. Me.lblExtendedPrice.Location = New System.Drawing.Point(290, 19)
  424. Me.lblExtendedPrice.Name = "lblExtendedPrice"
  425. Me.lblExtendedPrice.RightToLeft = System.Windows.Forms.RightToLeft.No
  426. Me.lblExtendedPrice.Size = New System.Drawing.Size(104, 19)
  427. Me.lblExtendedPrice.TabIndex = 10
  428. Me.lblExtendedPrice.TextAlign = System.Drawing.ContentAlignment.TopRight
  429. '
  430. 'Label7
  431. '
  432. Me.Label7.BackColor = System.Drawing.SystemColors.Control
  433. Me.Label7.Cursor = System.Windows.Forms.Cursors.Default
  434. Me.Label7.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  435. Me.Label7.ForeColor = System.Drawing.SystemColors.ControlText
  436. Me.Label7.Location = New System.Drawing.Point(187, 74)
  437. Me.Label7.Name = "Label7"
  438. Me.Label7.RightToLeft = System.Windows.Forms.RightToLeft.No
  439. Me.Label7.Size = New System.Drawing.Size(113, 20)
  440. Me.Label7.TabIndex = 13
  441. Me.Label7.Text = "Discounted Price"
  442. '
  443. 'Label6
  444. '
  445. Me.Label6.BackColor = System.Drawing.SystemColors.Control
  446. Me.Label6.Cursor = System.Windows.Forms.Cursors.Default
  447. Me.Label6.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  448. Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
  449. Me.Label6.Location = New System.Drawing.Point(187, 46)
  450. Me.Label6.Name = "Label6"
  451. Me.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No
  452. Me.Label6.Size = New System.Drawing.Size(132, 20)
  453. Me.Label6.TabIndex = 11
  454. Me.Label6.Text = "15% Discount"
  455. '
  456. 'Label5
  457. '
  458. Me.Label5.BackColor = System.Drawing.SystemColors.Control
  459. Me.Label5.Cursor = System.Windows.Forms.Cursors.Default
  460. Me.Label5.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  461. Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
  462. Me.Label5.Location = New System.Drawing.Point(187, 19)
  463. Me.Label5.Name = "Label5"
  464. Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
  465. Me.Label5.Size = New System.Drawing.Size(94, 19)
  466. Me.Label5.TabIndex = 9
  467. Me.Label5.Text = "Extended Price"
  468. '
  469. 'Label1
  470. '
  471. Me.Label1.BackColor = System.Drawing.SystemColors.Control
  472. Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
  473. Me.Label1.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  474. Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
  475. Me.Label1.Location = New System.Drawing.Point(187, 9)
  476. Me.Label1.Name = "Label1"
  477. Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
  478. Me.Label1.Size = New System.Drawing.Size(113, 20)
  479. Me.Label1.TabIndex = 0
  480. Me.Label1.Text = "Book Sales"
  481. '
  482. 'frmBooksale
  483. '
  484. Me.AcceptButton = Me.btnCalculate
  485. Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  486. Me.CancelButton = Me.btnClear
  487. Me.ClientSize = New System.Drawing.Size(592, 603)
  488. Me.Controls.Add(Me.grpSummary)
  489. Me.Controls.Add(Me.btnClear)
  490. Me.Controls.Add(Me.btnExit)
  491. Me.Controls.Add(Me.btnCalculate)
  492. Me.Controls.Add(Me.grpOutput)
  493. Me.Controls.Add(Me.grpInpt)
  494. Me.Controls.Add(Me.Label1)
  495. Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  496. Me.Location = New System.Drawing.Point(3, 18)
  497. Me.Name = "frmBooksale"
  498. Me.Text = "R 'n R for Reading 'n Refreshment"
  499. Me.grpInpt.ResumeLayout(False)
  500. Me.grpSummary.ResumeLayout(False)
  501. Me.grpOutput.ResumeLayout(False)
  502. Me.ResumeLayout(False)
  503.  
  504. End Sub
  505. #End Region
  506. ' dimension module-level variables and constants
  507. ' running total of quantity of books sold
  508. Dim mintQuantitySum As Integer
  509. ' Sum of all discounts
  510. Dim mdecDiscountSum As Decimal
  511. ' running total of sales after discount
  512. Dim mdecDiscountedPriceSum As Decimal
  513. ' count of sales today
  514. Dim mintSaleCount As Integer
  515. ' declare constants
  516. Const mdecDISCOUNT_RATE As Decimal = 0.15D
  517.  
  518. Private Sub frmBooksale_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  519.  
  520. End Sub
  521.  
  522. Private Sub btnCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
  523.  
  524. ' calculate price and discount
  525. Dim intQuantity As Integer
  526. Dim decPrice As Decimal
  527. Dim decExtendedPrice As Decimal
  528. Dim decDiscount As Decimal
  529. Dim decDiscountedPrice As Decimal
  530. Dim decAverageDiscount As Decimal
  531.  
  532. ' assign values to input variables
  533. Try
  534. intQuantity = Integer.Parse(txtQuantity.Text)
  535.  
  536. Try
  537. decPrice = Decimal.Parse(txtPrice.Text)
  538.  
  539. 'calculate values for individual sale
  540. decExtendedPrice = intQuantity * decPrice
  541. decDiscount = decExtendedPrice * mdecDISCOUNT_RATE
  542. decDiscountedPrice = decExtendedPrice - decDiscount
  543.  
  544. ' calculate values for all sales
  545. mintQuantitySum = intQuantity + mintQuantitySum
  546. ' could be written:
  547. ' mintQuantity += intQuantity
  548. mdecDiscountSum = mdecDiscountSum + decDiscount
  549. mdecDiscountedPriceSum = mdecDiscountedPriceSum + decDiscountedPrice
  550. mintSaleCount += 1
  551.  
  552. decAverageDiscount = mdecDiscountSum / mintSaleCount
  553.  
  554. 'format and display output for sale
  555. ' C in tostring formats it as currency
  556. lblExtendedPrice.Text = decExtendedPrice.ToString("C")
  557. lblDiscount.Text = decDiscount.ToString("C")
  558. lblDiscountedPrice.Text = decDiscountedPrice.ToString("C")
  559.  
  560. ' format and display summary values
  561. ' N in tostring formats it as a number
  562. lblQuantitySum.Text = mintQuantitySum.ToString("N")
  563. lblDiscountSum.Text = mdecDiscountedPriceSum.ToString("C")
  564. lblDiscountedAmountSum.Text = mdecDiscountedPriceSum.ToString("C")
  565. lblAverageDiscount.Text = decAverageDiscount.ToString("C")
  566.  
  567. Catch myErr As Exception
  568. MessageBox.Show("Error: " & myErr.Message, "Data Entry Error", MessageBoxButtons.OK, _
  569. MessageBoxIcon.Exclamation)
  570. With txtPrice
  571. .Clear()
  572. .Focus()
  573. End With
  574. End Try
  575.  
  576. Catch myErr As Exception
  577. MessageBox.Show("Error: " & myErr.Message, "Data Entry Error", MessageBoxButtons.OK, _
  578. MessageBoxIcon.Exclamation)
  579. With txtQuantity
  580. .Clear()
  581. .Focus()
  582. End With
  583. End Try
  584. End Sub
  585. End Class
Add Comment
Please, Sign In to add comment