 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 9th, 2004, 02:02 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Display highest test score
I have written this small vb.net program that a user can enter a test score and each time that they do, it displays the average test score and the number of test scores. I am confused though regarding the code to display the highest test score. Any help would be appreciated.
|
|

November 9th, 2004, 02:52 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Are you storing the results in a database? If so you can use a Select statement to pull the highest value for the test scores.
Like:
SELECT Max([TestScore]) FROM [TableName]
Replace "TestScore" with the column name(without brackets) for your test scores. Replace "TableName"(without brackets) with your table's name.
If you aren't using a database, please post some code and give a little more info. It makes it easier for us to help you.
J
|
|

November 9th, 2004, 02:58 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No I am not. The user just enters a test score each time they press enter
|
|

November 9th, 2004, 04:23 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
So how are you keeping track of the test scores? Are you storing them in an array?
J
|
|

November 9th, 2004, 04:59 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Actually, I am doing a self study program and at this point I am not storing the scores anywhere yet.
|
|

November 9th, 2004, 05:55 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
You said earlier that you were displaying average test scores and the number of test scores. How are you keeping track of these test scores?
Can you post some code and list exactly what you want? It is easier than me guessing each time.
|
|

November 9th, 2004, 06:53 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Operation
⢠The user enters a test score ranging from 0 to 100 and then clicks the Enter score button or presses the Enter key to activate that button.
⢠For each score, the application adds one to the number of scores, calculates the average score, and determines what the best score is so far. Then, it displays the results.
⢠To clear the results so the user can enter another set of scores, the user clicks on the Reset button.
This is the project that I am working on. I have been able to do the code for the average score and number of scores.
|
|

November 9th, 2004, 08:03 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
So I assume you are assigning these values to variables? Adding the new test score to a current total and then dividing that by the total number of tests + 1 (the new test).
I guess one way to do it would be to create a new numeric variable and assign to it the first test's value. Upon each submission you could compare the current test's value with the value stored in the variable. If it is greater, it replaces the variable's value with it's own.
J
|
|

November 9th, 2004, 08:05 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you very much for your input.
|
|

November 9th, 2004, 08:11 PM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That is exactly what I am doing. How would that part be coded. Can you give an example.
Thanks
|
|
 |