Each salesperson at Huntington Motors is assigned an ID number that consists of
ID: 3795473 • Letter: E
Question
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 A1 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 formalin. Create the interface shown in Figure 8-43. The car mage 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. Cars sold by full-time employees: Cars sold by part-time employees: Cars sold by new car employees: Cars sold by used car employees:Explanation / Answer
MainForm.vb
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
Dim intNumSold As Integer
Dim strSalesId As String
Dim intFullTimeSales As Integer
Dim intPartTimeSales As Integer
Dim intNewCars As Integer
Dim intUsedCars As Integer
strSalesId = txtIdInput.Text
intNumSold = txtNumSoldInput.Text
If strSalesId.Substring(0, 1) = 1 Then
intNewCars = intNumSold
lblNewCarsOut.Text = intNewCars
If strSalesId.Substring(3, 1).ToUpper = "F" Then
intFullTimeSales = intNumSold
lblFullTimeOut.Text = intFullTimeSales
ElseIf strSalesId.Substring(3, 1).ToUpper = "P" Then
intPartTimeSales = intNumSold
lblPartTimeOut.Text = intPartTimeSales
End If
ElseIf strSalesId.Substring(0, 1) = 2 Then
intUsedCars = intNumSold
lblUsedCarsOut.Text = intUsedCars
If strSalesId.Substring(3, 1).ToUpper = "F" Then
intFullTimeSales = intNumSold
lblFullTimeOut.Text = intFullTimeSales
ElseIf strSalesId.Substring(3, 1).ToUpper = "P" Then
intPartTimeSales = intNumSold
lblPartTimeOut.Text = intPartTimeSales
End If
End If
End Sub
End Class
MainForm.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.btnCalc = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.txtIdInput = New System.Windows.Forms.TextBox()
Me.txtNumSoldInput = New System.Windows.Forms.TextBox()
Me.lblID = New System.Windows.Forms.Label()
Me.lblNumSold = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.lblFullTimeOut = New System.Windows.Forms.Label()
Me.lblPartTimeOut = New System.Windows.Forms.Label()
Me.lblNewCarsOut = New System.Windows.Forms.Label()
Me.lblUsedCarsOut = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'btnCalc
'
Me.btnCalc.Location = New System.Drawing.Point(116, 58)
Me.btnCalc.Name = "btnCalc"
Me.btnCalc.Size = New System.Drawing.Size(75, 23)
Me.btnCalc.TabIndex = 0
Me.btnCalc.Text = "&Calculate"
Me.btnCalc.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(197, 58)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(75, 23)
Me.btnExit.TabIndex = 1
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'txtIdInput
'
Me.txtIdInput.Location = New System.Drawing.Point(116, 32)
Me.txtIdInput.Name = "txtIdInput"
Me.txtIdInput.Size = New System.Drawing.Size(74, 20)
Me.txtIdInput.TabIndex = 2
'
'txtNumSoldInput
'
Me.txtNumSoldInput.Location = New System.Drawing.Point(197, 32)
Me.txtNumSoldInput.Name = "txtNumSoldInput"
Me.txtNumSoldInput.Size = New System.Drawing.Size(75, 20)
Me.txtNumSoldInput.TabIndex = 3
'
'lblID
'
Me.lblID.AutoSize = True
Me.lblID.Location = New System.Drawing.Point(116, 13)
Me.lblID.Name = "lblID"
Me.lblID.Size = New System.Drawing.Size(21, 13)
Me.lblID.TabIndex = 4
Me.lblID.Text = "ID:"
'
'lblNumSold
'
Me.lblNumSold.AutoSize = True
Me.lblNumSold.Location = New System.Drawing.Point(194, 13)
Me.lblNumSold.Name = "lblNumSold"
Me.lblNumSold.Size = New System.Drawing.Size(69, 13)
Me.lblNumSold.TabIndex = 5
Me.lblNumSold.Text = "&Number sold:"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(19, 131)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(158, 13)
Me.Label1.TabIndex = 6
Me.Label1.Text = "Cars sold by full-time employees:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(19, 161)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(163, 13)
Me.Label2.TabIndex = 7
Me.Label2.Text = "Cars sold by part-time employees:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(19, 192)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(161, 13)
Me.Label3.TabIndex = 8
Me.Label3.Text = "Cars sold by new car employees:"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(19, 226)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(164, 13)
Me.Label4.TabIndex = 9
Me.Label4.Text = "Cars sold by used car employees:"
'
'lblFullTimeOut
'
Me.lblFullTimeOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblFullTimeOut.Location = New System.Drawing.Point(188, 131)
Me.lblFullTimeOut.Name = "lblFullTimeOut"
Me.lblFullTimeOut.Size = New System.Drawing.Size(41, 15)
Me.lblFullTimeOut.TabIndex = 10
'
'lblPartTimeOut
Me.lblPartTimeOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblPartTimeOut.Location = New System.Drawing.Point(188, 161)
Me.lblPartTimeOut.Name = "lblPartTimeOut"
Me.lblPartTimeOut.Size = New System.Drawing.Size(41, 15)
Me.lblPartTimeOut.TabIndex = 11
'
'lblNewCarsOut
'
Me.lblNewCarsOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblNewCarsOut.Location = New System.Drawing.Point(188, 192)
Me.lblNewCarsOut.Name = "lblNewCarsOut"
Me.lblNewCarsOut.Size = New System.Drawing.Size(41, 15)
Me.lblNewCarsOut.TabIndex = 12
'
'lblUsedCarsOut
'
Me.lblUsedCarsOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblUsedCarsOut.Location = New System.Drawing.Point(188, 226)
Me.lblUsedCarsOut.Name = "lblUsedCarsOut"
Me.lblUsedCarsOut.Size = New System.Drawing.Size(41, 15)
Me.lblUsedCarsOut.TabIndex = 13
'
'frmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 261)
Me.Controls.Add(Me.lblUsedCarsOut)
Me.Controls.Add(Me.lblNewCarsOut)
Me.Controls.Add(Me.lblPartTimeOut)
Me.Controls.Add(Me.lblFullTimeOut)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.lblNumSold)
Me.Controls.Add(Me.lblID)
Me.Controls.Add(Me.txtNumSoldInput)
Me.Controls.Add(Me.txtIdInput)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnCalc)
Me.Name = "frmMain"
Me.Text = "Huntington Motors"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnCalc As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents txtIdInput As System.Windows.Forms.TextBox
Friend WithEvents txtNumSoldInput As System.Windows.Forms.TextBox
Friend WithEvents lblID As System.Windows.Forms.Label
Friend WithEvents lblNumSold As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents lblFullTimeOut As System.Windows.Forms.Label
Friend WithEvents lblPartTimeOut As System.Windows.Forms.Label
Friend WithEvents lblNewCarsOut As System.Windows.Forms.Label
Friend WithEvents lblUsedCarsOut As System.Windows.Forms.Label
End Class
Huntington Project.vbproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6D6462A3-EBDE-4D1F-AB99-F96C49263A70}</ProjectGuid>
<OutputType>WinExe</OutputType>
<StartupObject>Huntington_Project.My.MyApplication</StartupObject>
<RootNamespace>Huntington_Project</RootNamespace>
<AssemblyName>Huntington Project</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>WindowsForms</MyType>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>binDebug</OutputPath>
<DocumentationFile>Huntington Project.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>binRelease</OutputPath>
<DocumentationFile>Huntington Project.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Diagnostics" />
<Import Include="System.Windows.Forms" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.vb">
<DependentUpon>MainForm.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="My ProjectAssemblyInfo.vb" />
<Compile Include="My ProjectApplication.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
<Compile Include="My ProjectResources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My ProjectSettings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My ProjectResources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My ProjectApplication.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="My ProjectSettings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.