Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. Public Class frmFurniture
  2.  
  3. Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
  4. Dim Name, Address, Zip As String, Chairs, Sofas As Double
  5. Name = txtName.Text
  6. Address = txtAddress.Text
  7. Zip = txtZip.Text
  8. Chairs = CDbl(txtChairs.Text)
  9. Sofas = CDbl(txtSofas.Text)
  10. Invoice(Name, Address, Zip, Chairs, Sofas)
  11.  
  12. End Sub
  13. Sub Invoice(ByRef Name As String, ByVal address As String, ByVal zip As String, ByVal chairs As Double, ByVal sofas As Double)
  14. Dim Invoice As String, SofaPrice, ChairPrice, Tax As Double
  15. Dim sr As IO.StreamReader = IO.File.OpenText("PRICE_TAXDATA.TXT")
  16. Dim fmtstr As String = "{0,12}|{1,10}"
  17. Dim basePrice, total As Double
  18. Invoice = InvoiceNum(Name, zip)
  19. ChairPrice = CDbl(sr.ReadLine)
  20. SofaPrice = CDbl(sr.ReadLine)
  21. Tax = CDbl(sr.ReadLine)
  22. basePrice = (ChairPrice * chairs) + (SofaPrice * sofas)
  23. total = (basePrice * Tax) + basePrice
  24. lstDisplay.Items.Add("Invoice Number: " & InvoiceNum(Name, zip))
  25. lstDisplay.Items.Add("")
  26. lstDisplay.Items.Add("Name: " & NameSwitch(Name))
  27. lstDisplay.Items.Add("Address: " & address)
  28. lstDisplay.Items.Add("City: " & zip)
  29. lstDisplay.Items.Add("")
  30. lstDisplay.Items.Add("Number of chairs: " & chairs)
  31. lstDisplay.Items.Add("Number of sofas: " & sofas)
  32. lstDisplay.Items.Add("")
  33. lstDisplay.Items.Add(String.Format(fmtstr, "Cost:", FormatCurrency(basePrice)))
  34. lstDisplay.Items.Add(String.Format(fmtstr, "Sales Tax", FormatCurrency(basePrice * Tax)))
  35. lstDisplay.Items.Add(String.Format(fmtstr, " ", "-----------"))
  36. lstDisplay.Items.Add(String.Format(fmtstr, "Total Cost:", FormatCurrency(total)))
  37. End Sub
  38. Function InvoiceNum(ByVal name As String, ByVal zip As String) As String
  39. Dim letterName = name.Substring(0, 2).ToUpper
  40. Dim numZip = zip.Substring(zip.Length - 5)
  41. Dim invoiceNumber As String
  42. invoiceNumber = letterName & numZip
  43. Return (invoiceNumber)
  44. End Function
  45. Public Function NameSwitch(ByVal name As String) As String
  46. Dim names = name.Split(","c)
  47. Dim firstName = names(1).Trim()
  48. Dim lastName = names(0).Trim()
  49. Return firstName + " " + lastName
  50. End Function
  51.  
  52. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
  53. txtAddress.Clear()
  54. txtChairs.Clear()
  55. txtName.Clear()
  56. txtSofas.Clear()
  57. txtZip.Clear()
  58. lstDisplay.Items.Clear()
  59. End Sub
  60.  
  61. Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
  62. Application.Exit()
  63. End Sub
  64. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement