Overview: This program prompts the user for his or her full name (First Last) delimited with one or more spaces. When the user clicks the calculate button, the name is parsed, capitalised and spaced correctly (Fred Bloggs, not fred bLoggs for example), the gross pay is calculated, and the results are displayed in textboxes. The user may then dismiss the application by clicking the exit button. This program uses one form, four labels, four textboxes, and two buttons.
The following table shows the required property settings for those objects.
Note: At the very top of your code window, insert **Option Strict On**. This will force you to use conversion functions to convert data types. Please read about this in the help.
| Object | Properties |
| Form | Name: frmMain
Text: Your name, Assignment 3, Your email address |
| Label | Text: Please enter your name, pay rate, and hours.
Font: 12pt, Courier New, Bold |
| Labels | Text: as indicated in the graphic below |
| TextBox | Name: txtFullName |
| TextBox | Name: txtPayRate |
| TextBox | Name: txtHoursWorked |
| TextBox | Name: txtOut
ReadOnly: True |
| Button | Name: btnCalculate
Text: _C_alculate Pay |
| Button | Name: btnExit
Text: E_x_it |
Your program's initial screen must look like this (after sample data has been entered). Remember to set a form title showing your name, the assignment number and your email details on all forms.
When the user clicks the button, your program must look like this (apart from the title):
Your program must exit when the user clicks the exit button.
Detailed SpecificationParsing Tasks:
Parse the user's name, change case as required and strip redundant blanks and display the corrected full name in the name textbox. Use local string variables for this part.
a) get the name
b) trim it as required (head, tail, additional spaces between words)
c) find the space between the first and last name and split the names or report an error
d) capitalize the initial letters of each name and lowercase the rest
e) reassemble the full name
f) assign the modified fullname to the name textbox
Methods/Functions used: Trim, IndexOf, Substring, ToUpper, ToLower
1. Calculate the user's gross pay = pay rate * hours worked. Use local single precision variables for this part
a) convert the pay rate and hours worked textbox values to single precision and assign to your variables
b) calculate the gross pay and assign it to a single precision variable.
Methods/Functions used: CSng
2. Build and display the output message in the output textbox. Use a string variable and vbCrLf to build the message.
Use concatenation and the format functions with vbCrLf to make the message look similar to the sample shown above.
Methods/Functions used: FormatNumber, FormatCurrency
[url removed, login to view]