CIS 125 - Project 3 (Chapter 5 Programming Project #3) Total 50 PTS
CIS 125 - Project 3 (Chapter 5 Programming Project #3) Total 50 PTS
Submit your word document, spreadsheet, code printout, and have me initial this spot
_____worked, _____ didnt work when you are done.
You should have the Form Object Documentation spread sheet ready to go. 10pts
For each section of code below:
1. explain what the code is doing in a word document. (15pts)
2. insert the code as a comment in your Form Object Documentation spreadsheet (10pts)
3. insert the code into your code editor attached to the correct object (15pts)
Code Section A.
Const COST_PER_CHAIR As Double = 350
Const COST_PER_SOFA As Double = 925
Const SALES_TAX_RATE As Double = 0.05
Code Section B.
Private Sub bntProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles bntProcess.Click
Dim cost As Double
Dim totalCost As Double
cost = COST_PER_CHAIR * CDbl(txtChairs.Text) + COST_PER_SOFA * CDbl(txtSofas.Text)
totalCost = cost + SALES_TAX_RATE * cost
lstInvoice.Items.Clear()
lstInvoice.Items.Add("Invoice Number: " & InvoiceNumber())
lstInvoice.Items.Add("")
lstInvoice.Items.Add("Name: " & NameInProperOrder())
lstInvoice.Items.Add("Address: " & txtAddress.Text)
lstInvoice.Items.Add("City: " & txtCityState.Text)
lstInvoice.Items.Add("")
lstInvoice.Items.Add("Number of Chairs: " & txtChairs.Text)
lstInvoice.Items.Add("Number of Sofas: " & txtSofas.Text)
lstInvoice.Items.Add("")
lstInvoice.Items.Add("
Cost:" & " " & FormatCurrency(cost))
lstInvoice.Items.Add("Sales Tax:" & " " & FormatCurrency(SALES_TAX_RATE * cost))
lstInvoice.Items.Add("
------------")
lstInvoice.Items.Add("Total Cost:" & " " & FormatCurrency(totalCost))
End Sub
Code Section C.
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnClear.Click
txtName.Text = ""
txtAddress.Text = ""
txtCityState.Text = ""
txtChairs.Text = ""
txtSofas.Text = ""
txtName.Focus()
lstInvoice.Items.Clear()
End Sub
Code Section D.
Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnQuit.Click
Me.Close()
End Sub
Code Section E.
Private Function InvoiceNumber() As String
Dim endOfZip, str As String
endOfZip = txtCityState.Text.Substring(txtCityState.Text.Length - 4)
str = txtName.Text.Substring(0, 2).ToUpper & endOfZip
Return str
End Function
Code Section F.
Private Function NameInProperOrder() As String
Dim name, firstName, lastName As String
Dim comma As Integer
name = txtName.Text
comma = name.IndexOf(",")
lastName = name.Substring(0, comma)
firstName = name.Substring(comma + 2)
Return firstName & " " & lastName
End Function
End Class