Wrox Programmer Forums
|
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
 
Old November 9th, 2004, 11:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Declare the variable outside of your procedures:

-----------------------------------------------------------
Private intHighTestScore as Int32 'variable to hold the high test score
-----------------------------------------------------------

Then, inside your click event for the submit button after you calculate the current score, I am using a variable called intCurrentScore but you can substitute whatever you currently have:

-----------------------------------------------------------
'process code to get the current test score here and assign
'it to the variable intCurrentScore

If intCurrentScore > intHighTestScore Then
  intHighTestScore = intCurrentScore
End If
-----------------------------------------------------------

You could then use the variable to display the score in a label, textbox, etc. The only problem is, once the application closes, you lose all of the information. A better way would be to store this data somewhere - a text file, database, etc.

J
 
Old November 10th, 2004, 06:54 AM
Authorized User
 
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you

You have been a great help.

 
Old November 10th, 2004, 09:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

No problem.

J
 
Old November 19th, 2004, 09:25 AM
Authorized User
 
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

With this accumulated data, how would I add these items to an array each time I add a new score.

 
Old November 19th, 2004, 10:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I don't think you need to add the high score and the average to an array since at any given time they are only going to equal a single number and you can store this in a single variable.

If you want to add other things, such as first name, lastname, score, etc., you can do something like this:

----------------------------------------
'declare these outside of any procedure
Structure Test
   Dim FirstName As String
   Dim LastName As String
   Dim TestScore As Byte
End Structure

Private Scores() As Test
Private intScoreCntr As Int32

---------------

'put this in your submit button click event
ReDim Preserve Scores(intScoreCntr)

Scores(intScoreCntr).FirstName = txtFName.Text
Scores(intScoreCntr).LastName = txtLName.Text
Scores(intScoreCntr).TestScore = txtScore.Text

txtFName.Text = ""
txtLName.Text = ""
txtScore.Text = ""

intScoreCntr += 1

----------------------------------------

Although this method will work, a much better way would be to store all of this information in a database.
 
Old November 19th, 2004, 11:02 AM
Authorized User
 
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again for your help

Ken






Similar Threads
Thread Thread Starter Forum Replies Last Post
Algorithm to Score Global Quality-Quantity of File asgarcymed VBScript 0 November 24th, 2007 11:12 PM
Coursebuilder Score Script fs22 Javascript 0 April 8th, 2004 09:37 AM
get max test score and corresponding date ssambr1 MySQL 1 January 24th, 2004 08:42 PM
quiz total score frenziedsilence Beginning PHP 2 January 14th, 2004 12:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.