' ' Calculate average scores ' 'For the purpose of this demo I've used text boxes. 'Ideally one would use labels rather than text boxes 'for displaying scores. That way we don't let the 'user cheat changing scores ;-)

' :-: Give credit where credit is due :-:

'I read an answer to a question in one of the vb 'news groups titled "Sums in VB3" by Markus 'markus.lausen@amd.com and ended up trying it myself 'So thanks go to Markus wherever you are.

'Also used in this demo is some code by Adnan Hasanovic 'which can be found at: 'http://www.freevbcode.com/ShowCode.Asp?ID=2377 'Nice 3D Effect, try it!

'Email: i-am@thepub.co.za

Option Explicit

Dim counter As Integer Dim sum As Integer

Private Sub cmdCalculate_Click() Dim i As Integer Dim average As String

'Set counter to 0 counter = 0

'Set sum to 0 sum = 0

'Count number of text boxes that have values 'in them and sum them. If any text box has no 'value (empty) then the counter excludes that 'box in the final equation For i = 0 To 4 If txtScores(i) <> "" And Not IsNumeric(txtScores(i)) Then MsgBox "All values must be numeric!" Exit Sub End If Next i

For i = 0 To 4 If txtScores(i) <> "" Then sum = sum + txtScores(i) counter = counter + 1 End If Next i