Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmFurniture
- 'Programmed by: ******
- 'CIS 115 - 9:30
- 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
- 'Getting the input
- Name = txtName.Text
- Address = txtAddress.Text
- Zip = txtZip.Text
- Chairs = CDbl(txtChairs.Text)
- Sofas = CDbl(txtSofas.Text)
- 'Calling a subprocedure to make the process and output
- 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)
- 'Reading the txt file
- ChairPrice = CDbl(sr.ReadLine)
- SofaPrice = CDbl(sr.ReadLine)
- Tax = CDbl(sr.ReadLine)
- sr.Close()
- basePrice = (ChairPrice * chairs) + (SofaPrice * sofas)
- total = (basePrice * Tax) + basePrice
- 'TIME TO LIST STUFF NOW - SEE BELOW
- 'Also... Using Function InvoiceNum to make the invoice number
- lstDisplay.Items.Add("Invoice Number: " & InvoiceNum(Name, zip))
- lstDisplay.Items.Add("")
- 'Calling the Function NameSwitch to switch last and first names for the invoice.
- 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 'Grabbing the first two letters of the last name and making them Upper
- 'Grabbing the last 5 digits (which would be the zip code)
- Dim numZip = zip.Substring(zip.Length - 5)
- Return letterName + numZip
- End Function
- Public Function NameSwitch(ByVal name As String) As String
- 'Splitting the names into 2 strings at the comma
- Dim names = name.Split(","c)
- Dim firstName = names(1).Trim() 'trimmed the spaces
- Dim lastName = names(0).Trim()
- Return firstName + " " + lastName 'Put them in the right form here
- End Function
- Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
- 'Clearing the text boxes and list box
- 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
- 'Quitting the form
- Application.Exit()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement