This is the Assimate Each salesperson at Rembrandt Auto-Mart is assigned an ID n
ID: 3817017 • Letter: T
Question
This is the Assimate
Each salesperson at Rembrandt Auto-Mart is assigned an ID number that consists of five characters. The first three characters are numbers. The fourth character is a letter: either the letter N if the salesperson sells new cars or the letter U if the salesperson sells used cars. The fifth character is also a letter: either the letter F if the salesperson is a full-time employee or the letter P if the salesperson is a part-time employee. Create an application, using the following names for the solution and project, respectively: Rembrandt Solution and Rembrandt Project. Save the application in the VB2015 Chap08 folder. Create the interface shown in Figure 8-40. Make the Calculate button the default button. The application should allow the sales manager to enter the ID and the number of cars sold for as many salespeople as needed. The btnCalc_Click procedure should 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. Test the application appropriately.
This is what i have numbers on not coming up for me
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Dim parttimeTotal As Integer = 0
Dim newTotal As Integer = 0
Dim usedTotal As Integer = 0
Dim fulltimeTotal As Integer = 0
Private Sub txtId_Enter(ByVal sender As Object, e As EventArgs) Handles txtId.Enter
txtId.SelectAll()
End Sub
Private Sub txtNumSold_Enter(ByVal sender As Object, e As EventArgs) Handles txtNumSold.Enter
txtNumSold.SelectAll()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'window close
If MessageBox.Show("Do you want to exit?", "My Application",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) _
= DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub btnCalc_Click(ByVal sender As Object, e As EventArgs) Handles btnCalc.Click
Dim id As String
Dim num As Integer
Dim fulltime As Integer
Dim parttime As Integer
Dim newcar As Integer
Dim usedcars As Integer
id = txtId.Text
'convert number of vehicles to number
Integer.TryParse(txtNumSold.Text, num)
'add NumSold to Total
fulltimeTotal = fulltimeTotal + fulltime
parttimeTotal = parttimeTotal + parttime
newTotal = newTotal + newcar
usedTotal = usedTotal + usedcars
Dim blnValidLength As Boolean = id.Length.Equals(5)
Dim blnId As Boolean = id.ToUpper Like "[12][A-Z][A-Z][FP]"
If Not blnValidLength Then
MessageBox.Show("Invalid ID. Must be 5 characters long, end in F or P")
Return
Else
If id.Chars(3).Equals("N"c) Then
newcar = CInt(txtNumSold.Text)
End If
If id.Chars(3).Equals("U"c) Then
usedcars = CInt(txtNumSold.Text)
End If
If id.Chars(4).Equals("F"c) Then
fulltime = CInt(txtNumSold.Text)
End If
If id.Chars(4).Equals("P"c) Then
parttime = CInt(txtNumSold.Text)
End If
'display the result
lblFulltimeAnswer.Text = fulltimeTotal.ToString
lblParttimeanswer.Text = parttimeTotal.ToString
lblNewcaranswer.Text = newTotal.ToString
lblUsedcarAsnwer.Text = usedTotal.ToString
End If
End Sub
End Class
Explanation / Answer
Public Class Form1
Dim newTotal_parttimeTotal As Integer = 0, newTotal_fulltimeTotal As Integer = 0, usedTotal_fulltimeTotal As Integer = 0, usedTotal_parttimeTotal As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim id As String = "999AA"
Dim c_num, newTotal_fulltimeTotal, newTotal_parttimeTotal, usedTotal_fulltimeTotal, usedTotal_parttimeTotal As Integer
Dim flage As Boolean = False
id = TextBox1.Text
Do Until flage = False
id = TextBox1.Text
If IsNumeric(Val(Microsoft.VisualBasic.Left(id, 3))) And Mid(id, 4, 1) = "N" Or Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "F" Or Mid(id, 5, 1) = "P" Then
flage = True
Else
MsgBox("Invalied ID,")
End If
Loop
c_num = TextBox2.Text
Do Until flage = False
c_num = TextBox2.Text
If IsNumeric(c_num) Then
flage = True
End If
Loop
MsgBox(Mid(id, 4, 1) & Mid(id, 5, 1))
Select Case id
Case Mid(id, 4, 1) = "N" And Mid(id, 5, 1) = "F"
newTotal_fulltimeTotal = newTotal_fulltimeTotal + c_num
Case Mid(id, 4, 1) = "N" And Mid(id, 5, 1) = "P"
newTotal_parttimeTotal = newTotal_parttimeTotal + c_num
Case Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "F"
usedTotal_fulltimeTotal = usedTotal_fulltimeTotal + c_num
Case Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "P"
usedTotal_parttimeTotal = usedTotal_parttimeTotal + c_num
End Select
ListBox1.Items.Add("New Fulltime Total: " & newTotal_fulltimeTotal & "New Parttime Total: " & newTotal_parttimeTotal & "Used Fulltime Total: " & usedTotal_fulltimeTotal & "Used Parttime Total: " & usedTotal_parttimeTotal)
End Sub
End Class
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
id = UCase(TextBox1.Text)
If IsNumeric(Val(Microsoft.VisualBasic.Left(id, 3))) And Mid(id, 4, 1) = "N" Or Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "F" Or Mid(id, 5, 1) = "P" Then
flage = True
Else
MsgBox("Invalied ID,")
End If
c_num = Val(TextBox2.Text)
If IsNumeric(c_num) Then
flage = True
Else
MsgBox("Invalied Num,")
End If
If flage = True Then
If Mid(id, 4, 1) = "N" And Mid(id, 5, 1) = "F" Then
NF_Total = NF_Total + c_num
Else
If Mid(id, 4, 1) = "N" And Mid(id, 5, 1) = "P" Then
NP_Total = NP_Total + c_num
Else
If Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "F" Then
UF_Total = UF_Total + c_num
Else
If Mid(id, 4, 1) = "U" And Mid(id, 5, 1) = "P" Then
UP_Total = UP_Total + c_num
End If
End If
End If
End If
End If
ListBox1.Items.Add("New Fulltime Total: " & NF_Total & "__New Parttime Total: " & NP_Total & "__Used Fulltime Total: " & UF_Total & "__Used Parttime Total: " & UP_Total)
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.