Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Public Class frmFurniture
  2. 'Programmed by: ******
  3. 'CIS 115 - 9:30
  4.  
  5. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
  6. Dim Name, Address, Zip As String, Chairs, Sofas As Double
  7. 'Getting the input
  8. Name = txtName.Text
  9. Address = txtAddress.Text
  10. Zip = txtZip.Text
  11. Chairs = CDbl(txtChairs.Text)
  12. Sofas = CDbl(txtSofas.Text)
  13. 'Calling a subprocedure to make the process and output
  14. Invoice(Name, Address, Zip, Chairs, Sofas)
  15. End Sub
  16. Sub Invoice(ByRef Name As String, ByVal address As String, ByVal zip As String, ByVal chairs As Double, ByVal sofas As Double)
  17. Dim Invoice As String, SofaPrice, ChairPrice, Tax As Double
  18. Dim sr As IO.StreamReader = IO.File.OpenText("PRICE_TAXDATA.TXT")
  19. Dim fmtstr As String = "{0,12}|{1,10}"
  20. Dim basePrice, total As Double
  21. Invoice = InvoiceNum(Name, zip)
  22. 'Reading the txt file
  23. ChairPrice = CDbl(sr.ReadLine)
  24. SofaPrice = CDbl(sr.ReadLine)
  25. Tax = CDbl(sr.ReadLine)
  26. sr.Close()
  27. basePrice = (ChairPrice * chairs) + (SofaPrice * sofas)
  28. total = (basePrice * Tax) + basePrice
  29. 'TIME TO LIST STUFF NOW - SEE BELOW
  30. 'Also... Using Function InvoiceNum to make the invoice number
  31. lstDisplay.Items.Add("Invoice Number: " & InvoiceNum(Name, zip))
  32. lstDisplay.Items.Add("")
  33. 'Calling the Function NameSwitch to switch last and first names for the invoice.
  34. lstDisplay.Items.Add("Name: " & NameSwitch(Name))
  35. lstDisplay.Items.Add("Address: " & address)
  36. lstDisplay.Items.Add("City: " & zip)
  37. lstDisplay.Items.Add("")
  38. lstDisplay.Items.Add("Number of chairs: " & chairs)
  39. lstDisplay.Items.Add("Number of sofas: " & sofas)
  40. lstDisplay.Items.Add("")
  41. lstDisplay.Items.Add(String.Format(fmtstr, "Cost:", FormatCurrency(basePrice)))
  42. lstDisplay.Items.Add(String.Format(fmtstr, "Sales Tax", FormatCurrency(basePrice * Tax)))
  43. lstDisplay.Items.Add(String.Format(fmtstr, " ", "-----------"))
  44. lstDisplay.Items.Add(String.Format(fmtstr, "Total Cost:", FormatCurrency(total)))
  45. End Sub
  46. Function InvoiceNum(ByVal name As String, ByVal zip As String) As String
  47. Dim letterName = name.Substring(0, 2).ToUpper 'Grabbing the first two letters of the last name and making them Upper
  48. 'Grabbing the last 5 digits (which would be the zip code)
  49. Dim numZip = zip.Substring(zip.Length - 5)
  50. Return letterName + numZip
  51. End Function
  52. Public Function NameSwitch(ByVal name As String) As String
  53. 'Splitting the names into 2 strings at the comma
  54. Dim names = name.Split(","c)
  55. Dim firstName = names(1).Trim() 'trimmed the spaces
  56. Dim lastName = names(0).Trim()
  57. Return firstName + " " + lastName 'Put them in the right form here
  58. End Function
  59.  
  60. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
  61. 'Clearing the text boxes and list box
  62. txtAddress.Clear()
  63. txtChairs.Clear()
  64. txtName.Clear()
  65. txtSofas.Clear()
  66. txtZip.Clear()
  67. lstDisplay.Items.Clear()
  68. End Sub
  69.  
  70. Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
  71. 'Quitting the form
  72. Application.Exit()
  73. End Sub
  74. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement