Question

The following form will be used to determine the sales commission of employees. Using Visual Basic Studio, build the form with these features:

 The checkbox “Target Met” must be disabled.

 The title of the form should appear as “Sales Commissions”

Write the code to do the following: After entering the totals sales, the checkbox will automatically be checked if the average sales per month was $1,500 or more.

Note: The average sales per month can be calculated by dividing (total sales/months).

When the “Determine Sales Commission” button is clicked, the program must first check that there is no bad data entered into the textboxes. This means:

 Employee’s name must be entered.

 Both months and total sales must be numbers.

 The number of months entered must be between 0-12.

 Total sales must be a positive number.

 Any other data entered should result in showing an error message.

a. Write the code for the data validation as described above.

b. After that, input data from the textboxes into created variables. Do not forget to convert the data to its appropriate datatype as needed.

Under the same button “Determine Sales Commission”, and after the data validation from Q3, write the code that shows the following in the list box:

 The name of the employee.

 Number of months worked.

 Total sales.

 Average sales per month (Calculated as Total Sales / Months)

 A message about meeting the target, for example: “Target Met” or “Target Not met” This is based on the criteria of having average sales per month = $1,500 or more.

a. Under the same button, and after the code you completed for Q4, call a function named “GetCommission”. This function will receive the months and total sales, and returns the dollar amount of the employee’s commission to be added into the listbox.

b. Next, create the function “GetCommission” which received number of months and total sales, and returns the commission. (30) If target was not met, the commission will be 5% of all sales. Otherwise, the commission is calculated as 10% of the amount that met the target plus 15% of all additional sales. Mathematical Equations:

a. Target not met: Commission = 0.05 x TotalSales

b. Target met: Commission = (months x 1,500 x 0.10) + (0.15 x (TotalSales – (months x 1,500)))

Write the code for the clear button that:

 Clears all textboxes.

 Clears the checkbox.

 Clears the listbox

 Places the cursor in the first text box “Employee’s Name”

Sales Commissions Emplyees Name Number of Working Months Toal Sales S$ 洞[][]0 Target Mt Detemine Sales Commission Clear Employees Name XxX Months Worked 4 Total Sales $7,000.00 Average Sales Per Month$1.750.00 Target Met Commission$750.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Create a new windows form application in visual basic

2. Add controls like lable , text Boxes, buttons, check box and listbox in form

3. Change Text on lables

4. Change Text on buttons as "Determine Sales Commission" and "Clear" and change their Name property as "btnSales" and "btnClear"

5. Change Name property of textBoxes to txtName, txtMonths, txtSales

6. Change Name property of checkbox to CheckBoxTarget

7. Change Name property of list box to ListBoxDetails

Code-

Public Class Form4
Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CheckBoxTarget.Enabled = False 'Disable checkbox on form load
End Sub

Private Sub btnSales_Click(sender As Object, e As EventArgs) Handles btnSales.Click

' Declare variables
Dim avgSales As Double = 0
Dim commission As Double = 0
Dim message As String = ""

' Call dalaValidation function
' If it returns true, then calculate average sales and commission
If (dataValidation()) Then

'Store entered months in months variable
'Store entered total sales in sales variable
Dim months As Integer = Convert.ToInt32(txtMonth.Text.ToString())
Dim sales As Integer = Convert.ToInt32(txtSales.Text.ToString())

' Calculate average sales
avgSales = sales / months

' If avgSales>=1500, set message to "target met" else "target not met"
' and calculate commission accordingly
If (avgSales >= 1500) Then
CheckBoxTarget.Checked = True
commission = (months * 1500 * 0.1) + (0.15 * (sales - (months * 1500)))
message = "Target Met"
Else
commission = 0.05 * sales
message = "Target not met"

End If

' Display details in list box by adding details one by one to items
ListBoxDetails.Items.Add("Employee Name " + txtName.Text.ToString())
ListBoxDetails.Items.Add("Months Worked " + months.ToString())
ListBoxDetails.Items.Add("Total Sales $" + sales.ToString("N2"))
ListBoxDetails.Items.Add("Average sales per month $" + avgSales.ToString("N2"))
ListBoxDetails.Items.Add(message)
ListBoxDetails.Items.Add("Commission $" + commission.ToString("N2"))
End If
End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
'Clear all fields
txtName.Clear()
txtSales.Clear()
txtMonth.Clear()
ListBoxDetails.Items .Clear ()
CheckBoxTarget.Checked = False
txtName.Focus()
End Sub

Private Function dataValidation() As Boolean

' valid variable to represent if data is valid or not
Dim valid As Boolean = False
Dim name As String = txtName.Text.ToString()

' If name is empty, show error message
' Else check other data validation
' Check if month is numeric
' Check if sales is numeric
' If all are valid check if month is between 0-12
' Check if sales > 0
' If these 2 are valid as well, set valid = true
' Return valid
If (txtName.Text.ToString().Equals("")) Then
MessageBox.Show("Name cannot be empty!!")
ElseIf (IsNumeric(txtSales.Text) <> True) Then
MessageBox.Show("Sales must be numeric!!")
ElseIf (IsNumeric(txtMonth.Text) <> True) Then
MessageBox.Show("Month must be numeric!!")
Else
Dim months As Integer = Convert.ToInt32(txtMonth.Text.ToString())
Dim sales As Integer = Convert.ToInt32(txtSales.Text.ToString())
If (months <= 0 Or months > 12) Then
MessageBox.Show("Month must be between 0-12 !!")
ElseIf (sales < 0) Then
MessageBox.Show("Sales must be positive !!")
Else
valid = True
End If
End If

Return valid
End Function
End Class

SCREENSHOT

2 references Public Class Form4 0 references Private Sub Form4_Load (sender As Object, e As EventArgs) Handles MyBase.Load ChIf (avgSales >= 1500) Then 27 28 29 30 31 32 CheckBoxTarget.checked = True commission = (months * 1500 * 0.1) + (0.15 * (saleMessageBox. Show(Sales must be positive !!) 83 84 85 86 87 Else valid True End If End If Return valid 89 90 91 End Class En

OUTPUT-

Employees Name Number Of Working Months Total Sales S$ 7000 Target Met Determine Sales Commission Clear Name cannot be empty

Add a comment
Know the answer?
Add Answer to:
The following form will be used to determine the sales commission of employees. Using Visual Basic...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels,...

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

  • Visual Basic Programming Step 1-2 not important, it's just file naming.

    Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...

  • the code is in visual basic 376 Chapter 6 Loop Structures Case Programming Assignments con Most...

    the code is in visual basic 376 Chapter 6 Loop Structures Case Programming Assignments con Most Rainfall in the USA USE CASE DEFINITION e Windows application opens with the heading "Most Rainfall in US - Kauai," a ListBox object that displays the monthly rainfall amounts, an i amounts in inches mage, and a Button object that allows the user to begin entering their rainfall 2. A menu bar displays the File menu, which has two menu items: Clear and Exit....

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • I need help regarding my Visual Basic code ISC/ITE 285 Homework Due: Monday, January 28 by...

    I need help regarding my Visual Basic code ISC/ITE 285 Homework Due: Monday, January 28 by 11:55 pm Create a text file named "Grades.txt" which will contain a list of numeric grades. Save the file in the projects Bin/Debug folder. A sample of the file contents is shown below: 80 96 95 86 54 97 Create a string array that will be populated from the file "Grades.txt" when the array is created (Class-level array). Also create a numeric array that...

  • help me in Question please

    You must exercise a number of classes while using the inheritance rules we have learned.In each department must be realized, in addition to what is detailed below:.get, set methods-Property for all variables.ToString () -Equals () -- Builders of three types we learned.1. Write an Employee Department that represents a regular employee. For the department to keep theThe following data:Employee's nameBase salary (integer).behavior:Wage calculation method (equal to base salary).2. SalesEmployee Department - Represents a sales employee. For a sales employee keep...

  • Write the pseudocode for the following: A company needs to print pay-slips for its employees. Each record contains the following: a. number, b. name, c. hours, d. gender, and e. code. Each employee’s...

    Write the pseudocode for the following: A company needs to print pay-slips for its employees. Each record contains the following: a. number, b. name, c. hours, d. gender, and e. code. Each employee’s gross pay must be calculated and deductions made on the following basis: CODE 1: Full-time employee: Rate R30 per hour Deductions: Men PAYE 15% of gross pay, Medical aid R200 Women PAYE 10% of gross pay Medical aid R100 CODE 2: Part-time employee: Rate R20 per hour...

  • Can you solve this proble by using C# application? C# is one of programming languages supported...

    Can you solve this proble by using C# application? C# is one of programming languages supported by Visual Studio 2015. It combines the features of Java and C ++ and is suitbale for rapid application development. A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 4% and the county sales tax rate is 2%. Create an...

  • An Introduction to Programming Using Visual Basic Tenth Edition Chapter 3 Programming Project 2 What is...

    An Introduction to Programming Using Visual Basic Tenth Edition Chapter 3 Programming Project 2 What is the solution to this project? one of the numbers in an input text box is change the type of Auto Repair Calculator X Customer: John Doe Hours of labor: 3.5 Cost of parts and supplies 84.55 Display Bill + First number 21 Second number 77 х Customer Labor cost Parts cost Total cost John Doe $122.50 $88.78 $211.28 21 x 77 = 1617 FIGURE...

  • Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for...

    Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for program with ALL conditions met. Conditions to be met: Word Problem A person inherits a large amount of money. The person wants to invest it. He also has to withdraw it annually. How many years will it take him/her to spend all of the investment that earns at a 7% annual interest rate? Note that he/she needs to withdraw $40,000.00 a year. Also there...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT