Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmFurniture
- Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
- Dim Name, Address, Zip As String, Chairs, Sofas As Double
- Name = txtName.Text
- Address = txtAddress.Text
- Zip = txtZip.Text
- Chairs = CDbl(txtChairs.Text)
- Sofas = CDbl(txtSofas.Text)
- Invoice(Name, Address, Zip, Chairs, Sofas)
- End Sub
- Sub Invoice(ByRef Name As String, ByVal address As String, ByVal zip As String, ByVal chairs As Double, ByVal sofas As Double)
- Dim Invoice As String, SofaPrice, ChairPrice, Tax As Double
- Dim sr As IO.StreamReader = IO.File.OpenText("PRICE_TAXDATA.TXT")
- Dim fmtstr As String = "{0,12}|{1,10}"
- Dim basePrice, total As Double
- Invoice = InvoiceNum(Name, zip)
- ChairPrice = CDbl(sr.ReadLine)
- SofaPrice = CDbl(sr.ReadLine)
- Tax = CDbl(sr.ReadLine)
- basePrice = (ChairPrice * chairs) + (SofaPrice * sofas)
- total = (basePrice * Tax) + basePrice
- lstDisplay.Items.Add("Invoice Number: " & InvoiceNum(Name, zip))
- lstDisplay.Items.Add("")
- lstDisplay.Items.Add("Name: " & NameSwitch(Name))
- lstDisplay.Items.Add("Address: " & address)
- lstDisplay.Items.Add("City: " & zip)
- lstDisplay.Items.Add("")
- lstDisplay.Items.Add("Number of chairs: " & chairs)
- lstDisplay.Items.Add("Number of sofas: " & sofas)
- lstDisplay.Items.Add("")
- lstDisplay.Items.Add(String.Format(fmtstr, "Cost:", FormatCurrency(basePrice)))
- lstDisplay.Items.Add(String.Format(fmtstr, "Sales Tax", FormatCurrency(basePrice * Tax)))
- lstDisplay.Items.Add(String.Format(fmtstr, " ", "-----------"))
- lstDisplay.Items.Add(String.Format(fmtstr, "Total Cost:", FormatCurrency(total)))
- End Sub
- Function InvoiceNum(ByVal name As String, ByVal zip As String) As String
- Dim letterName = name.Substring(0, 2).ToUpper
- Dim numZip = zip.Substring(zip.Length - 5)
- Dim invoiceNumber As String
- invoiceNumber = letterName & numZip
- Return (invoiceNumber)
- End Function
- Public Function NameSwitch(ByVal name As String) As String
- Dim names = name.Split(","c)
- Dim firstName = names(1).Trim()
- Dim lastName = names(0).Trim()
- Return firstName + " " + lastName
- End Function
- Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
- txtAddress.Clear()
- txtChairs.Clear()
- txtName.Clear()
- txtSofas.Clear()
- txtZip.Clear()
- lstDisplay.Items.Clear()
- End Sub
- Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
- Application.Exit()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement