Visual Basic In this project you will create a program that
Visual Basic-
In this project, you will create a program that will calculate and display the career statistics for a hockey player. The program will input the name of the hockey player (the name must be a non-empty string) and the number of seasons played, which must be at least one season and no more than 20 seasons. Processing the goals and assists cannot start until a valid “seasons” value is provided. Once the valid Seasons value is provided, the program will prompt the user to provide the number of goals and assists for each of those seasons. The valid number of goals is between 0 and 60 and the valid number of assists is between 0 and 60. The program will keep a running total of the number of goals, the number of assists, and the total points. Also, a list of each season’s data will be displayed after the season data is provided. Once all the season data are collected, the program shall list the summary information for the player and the totals for all seasons. See the suggested pseudocode below for processing details.
Consider using the following pseudocode as a guide in developing the main processing algorithm of the program:
1. Accept and validate PLAYER NAME (from InputBox.)
2. Accept and validate SEASONS (from InputBox.)
3. Initialize display of data.
4. Loop with Counter from 1 to Seasons:
a. Accept and validate GOALS (from InputBox).
b. Accept and validate ASSISTS (from InputBox).
c. Display this season’s data (Goals and Assists).
d. Accumulate Goals and Assists into TotalGoals and TotalAssists.
5. Display TotalGoals, TotalAssists, and Points (TotalGoals + TotalAssists.)
Step 3: Suggested Form Design You are free to experiment with form design and object colors as you see fit, even though as to colors we strongly recommend using the default colors for the form and all objects – this allows each user to see your form in their chosen Windows color palette. The suggested form design is as follows: The InputBox() function that is suggested for data input should display a dialog box similar to the following one: Why the InputBox() function? Well, the standard way to accept free-format input from the user in any GUI program is through textboxes, of course, as we have been doing in previous Labs. In non-GUI programs, however, there are many such as in embedded systems, for example, and many other situations. For such programs, an specific “Accept Input” operation must be executed, and that is where the InputBox() function comes in. By learning how to use the InputBox() function in this program, you will learn to handle such operations in non-GUI programs as well, even though we will do it within our Windows, GUI programs, of course.
Step 4: Implement the Event Handlers Consider using the following suggested TOE chart as guide in designing your program’s event handlers: Task Object Event
1. Accept and validate PLAYER NAME (from InputBox.)
2. Accept and validate SEASONS (from InputBox.)
3. Initialize display of data.
4. Loop with Counter from 1 to Seasons:
a. Accept and validate GOALS (from InputBox).
b. Accept and validate ASSISTS (from InputBox).
c. Display this season’s data (Goals and Assists).
d. Accumulate Goals and Assists into TotalGoals and TotalAssists.
5. Display TotalGoals, TotalAssists, and Points (TotalGoals + TotalAssists.) btnProcess Click Clear all textboxes and listbox btnClear Click Close form btnExit Click Programming notes:
1. As shown in the reading, use a Do..Loop or For..Next statement to collect the season’s data, along with each season’s goals and assists information.
2. When doing this loop obtaining the data for each season, use InputBox() functions to accept the data from the user. (Please check p. 88 of our textbook for details on this function and please post question in class for clarification, if needed.)
3. Please note that the InputBox() function is simple and it does NOT allow us to check to see if the user clicked on the Cancel button to exit the dialogue. As such, there is no way to distinguish in our code between a user that enters nothing and clicks on “OK” and a user that may enter something but then clicks on “Cancel”. In both cases, the returned string will be a null (empty) string: “”.
4. Given the nefarious consequences of its use in programs, the GoTo statement CANNOT be used in this nor in any other program in our class. Instead of the GoTo statement, use Do..Loop statements.
5. As shown in the reading, use a Listbox to list each season’s information.
6. Do not allow using the button to get the statistics until the number of seasons has been validated. Please remember to set Option Strict On / Explicit On / Infer Off and also to supply profuse internal documentation in your program.
Solution
Build the Form
The following is the Object, Property, Setting, Event chart for the form controls, and each input field will have a label/input field pair. Also, group the related information in the associated group box.
The form and form controls will be logically placed on the form, the controls aligned and sized, and a logical tab order will be assigned to each of the form controls.
Hint: Button and Menu controls can use the same Click event handler, such as:
Private Sub btnGetStats_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
btnGetStats.Click, _
mnuGetStats.Click
Hint: When creating files, use the default path “bin\\debug”. This will allow you to move your project between machines and for submittal since the file will be included in the set of project files. For example, the following will create or open a file called “PlayerStats.txt” in the bin\\debug folder:
statsFile = System.IO.File.AppendText(\"PlayerStats.txt\")
Hint: Use the examples in section 8.1, page 350-351 to read the file and display the summary data in a datagridview control.
Build the Form
The following is the Object, Property, Setting, Event chart for the form controls, and each input field will have a label/input field pair. Also, group the related information in the associated group box.
The form and form controls will be logically placed on the form, the controls aligned and sized, and a logical tab order will be assigned to each of the form controls.
Hint: Button and Menu controls can use the same Click event handler, such as:
Private Sub btnGetStats_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
btnGetStats.Click, _
mnuGetStats.Click
Hint: When creating files, use the default path “bin\\debug”. This will allow you to move your project between machines and for submittal since the file will be included in the set of project files. For example, the following will create or open a file called “PlayerStats.txt” in the bin\\debug folder:
statsFile = System.IO.File.AppendText(\"PlayerStats.txt\")
Hint: Use the examples to read the file and display the summary data in a datagridview control.
Hockey Player Statistics Main Form
Object Property Setting
frmHockeyStats Text Hockey Player Statistics
lblHeading Text Name, Course Title, Week Number, Lab Title
grpPlayer Text Player Information
lblFirstName Text First Name:
txtFirstName Text (empty)
txtFirstName Tootip on Tooltip1 Player’s first name
lblLastName Text Last Name:
txtFirstName Text (empty)
txtFirstName Tootip on Tooltip1 Player’s last name
lblSeasons Text Number of Seasons:
txtSeasons Text (empty)
txtSeasons Tootip on Tooltip1 Number of seasons played
lblAge Text Rookie Age
txtAge Text (empty)
txtAge Tootip on Tooltip1 Rookie age of the player
grpStatistics Text Statistic Operations
btnGetStats Text Get Player Statistics
btnGetStats Tootip on Tooltip1 Click to enter player statistics
grpResults Text Season Results
lstSeasons Items (empty)
lstSeasons Tootip on Tooltip1 Season by season goals, assists, and total points
lblTotal Text (empty)
grpOperations Text Operations
btnSummary Text Display Summary
btnSummary Tootip on Tooltip1 Click to open player summary form
btnClear Text Clear
btnClear Tootip on Tooltip1 Click to clear all input and output data
btnExit Text Exit
btnExit Tootip on Tooltip1 Click to exit the Hockey Player statistics program
mnuFile Text File
mnuClear Text Clear Form
mnuExit Text File
mnuTools Text Tools
mnuGetStats Text Get Player Statistics
mnuSummary Text Summary Data
Player Summary Form
Object Property Setting
frmPlayerSummary Text Player Summary
lblHeading Text Player’s Season Summary
grpOperations Text Operations
btnGetStats Text Season Summary
btnGetStats Tootip on Tooltip1 Click to retrieve and display summary data
btnClear Text Clear Summary
btnClear Tootip on Tooltip1 Click to clear summary data file
btnClose Text Close Summary
btnClose Tootip on Tooltip1 Click to close the summary form
dgvStatistics Text (empty)
dgvStatistics Tootip on Tooltip1 All players career goals, assists, and points
You are free to experiment with colors and form design as you see fit. However, your application must meet the listed requirements.
Step 4: Implement the Event Handlers
Use the following as the design for your event handlers, referring to the flowchart for rules on input validation and processing. The final calculation SHOULD NOT be completed until all the input fields are validated.
Note that some of the event handlers use the same modules to perform the operations.
Hockey Player Statistics Main Form
Control Name Event Task
txtFirstName Validating Get player first name
Validate player name
txtLastName Validating Get player first name
Validate player name
txtSeasons Validating Get number of seasons
Validate number of seasons
txtAge Validating Get age
Validate age
Enable/disable get statistics command button
btnGetStats/mnuGetStats Click Collect Statistics
Display Summary Data
btnClear/mnuClear Click Clear all textboxes and output label
btnExit/mnuExit Click Close program (Hint: use “Application.Exit”)
btnSummary/mnuSummary Click Open Summary Form
frmHockeyStats Load Clear all textboxes and output label (Hint: call the ClearFields module)
Player Summary Form
Control Name (frmPlayerSummary) Event Task
btnGetStats Click Read Summary File
Display Summary Data
btnClear Click Open file for writing in CreateText mode
Close file
Display confirmation message
btnClose Click Close form (Hint: use “Me.Close”)
Step 5: Executing the Program
To execute your code, click Start and then start debugging. Check your output to ensure that you have space(s) where appropriate. If you need to fix anything, close your execution window and modify your code as necessary and rebuild.
Step 6: Deliverables
1. Capture a screen print of your output [Do a PRINT SCREEN and paste into an MS Word document].
2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
3. Save the Word document as CIS170A_Lab07_LastName_FirstInitial
4. Zip up the Word document along with complete set of project files into a single document.
5. Place deliverables in the Dropbox.
END OF LAB



