Programming with microsoft VB 2012 6th edition Question : I need help creating t
ID: 3796682 • Letter: P
Question
Programming with microsoft VB 2012 6th edition
Question: I need help creating the code for the below Ch 8 Lc Ex 8 pg 521 Fig 8-43 (55yr old returning to college!)?
Problem
Each salesperson at Huntington Motors is assigned an ID number that consists of four characters. The first character is either the number 1 or the number 2. A 1 indicates that the salesperson sells new cars, and a 2 indicates that the salesperson sells used cars. The middle two characters are the salesperson’s initials, and the last character is either the letter F or the letter P. The letter F indicates that the salesperson is a full-time employee. The letter P indicates that he or she is a part-time employee. Create a Visual Basic Windows application. Use the following names for the solution and project, respectively: Huntington Solution and Huntington Project. Save the application in the VB2012Chap08 folder. Change the form file’s name to Main Form.vb. Change the form’s name to frmMain. Create the interface shown in Figure 8-43. The car image in the picture box is contained in the VB2012Chap08Car.png file. (The image was downloaded from the Open Clip Art Library at http://openclipart.org.) Make the Calculate button the default button. The application should allow the sales manager to enter the ID and number of cars sold for as many salespeople as needed. The application should calculate and display the total number of cars sold by each of the following four categories of employees: full-time employees, part-time employees, employees selling new cars, and employees selling used cars. Code the application. Save the solution and then start and test the application. Close the Code Editor window and then close the solution.
Thanks
Explanation / Answer
Option Explicit On Option Strict On Option Infer Off Public Class frmMain Dim intTotalPart As Integer = 0 Dim intTotalNew As Integer = 0 Dim intTotalUsed As Integer = 0 Dim intTotalFull As Integer = 0
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim intFirstChar As Integer
Dim strLastChar As String
Dim strID As String
strID = lblID.Text.Trim.ToUpper
If strID.Length <> 4 Then
lblID.Text = String.Empty
lblFullTime.Text = String.Empty
MessageBox.Show("The ID must have four characters", "ID", MessageBoxButtons.OK)
Else
intFirstChar = strID.Substring(0, 1)
If intFirstChar = "1" Then
ElseIf intFirstChar = "2" Then
lblUsed.Text = Convert.ToInt32(lblNumberSold.Text) + Convert.ToInt32(lblUsed.Text)
Else
strLastChar = strID.Substring(5, 1)
If strLastChar = "P" Then
lblPartTime.Text = Convert.ToInt32(lblNumberSold.Text) + Convert.ToInt32(lblPartTime.Text)
ElseIf strLastChar = "F" Then
lblFullTime.Text = Convert.ToInt32(lblNumberSold.Text) + Convert.ToInt32(lblFullTime.Text)
Else
MessageBox.Show ("The ID Must begin with the Number 1 or 2 and end with the letter P or F", "Item",MessageBoxButtons.OK)
End If
End If
End If
End Sub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.