|
-
Feb 8th, 2012, 07:59 PM
#1
Thread Starter
New Member
Test Score Calc
I'm not sure where I'm going wrong with this. it's supposed to let the user add scores to the list, then calculate the total, average, and count. However, it doesn't let me add more values to the list. Any help whatsoever would be awesome!
Keep in mind, I am new to VB and programming languages, and was just playing around with code hoping for any sort of positive result, and therefore some of the code may not be necessary, or make sense.
Here's what I have now:
Private Sub addbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addbutton.Click
Dim scoreList As New List(Of Integer)
Dim score As Integer
If TextBox1.Text >= 0 And TextBox1.Text <= 100 Then
scoreList.Add(CInt(TextBox1.Text))
Dim num As Integer
For Each num In scoreList
Console.WriteLine(num)
Next
Dim i As Integer
For i = 0 To scoreList.Count - 1
Console.WriteLine(scoreList.Item(i))
Next i
score = TextBox1.Text
Dim scoreTotal As Integer = scoreTotal + score
TextBox2.Text = scoreTotal
Dim scoreCount As Integer = scoreCount + 1
TextBox3.Text = scoreCount
Dim scoreAverage As Decimal = Math.Round(scoreTotal / scoreCount, 2)
TextBox4.Text = scoreAverage
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|