I doing the common 'enter scores, total, average and display" problem as I'm learning VB (see screenshot). It works great with the following code:
___________
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim score As Integer = score
Static scoreTotal As Integer = scoreTotal
Static numberOfScores As Integer
Dim averageScore As Decimal

numberOfScores += 1
score = TextBox1.Text
scoreTotal = scoreTotal + TextBox1.Text
averageScore = (scoreTotal / numberOfScores)

Me.TextBox1.Text = score
Me.TextBox2.Text = scoreTotal
Me.TextBox3.Text = numberOfScores
Me.TextBox4.Text = averageScore
____________

But then I have to code the button that displays the individual scores. I know how to make the message box come up, but I can't call up all the individual scores that have been entered. I know this doesn't work:

____
'Dim scoresString As String
'For i As Integer = 0 To scores.Length - 1
'scores() &= scores(9).ToString
'scores(i) = i
'Next
______

How do I get VB to save the scores as score(0), score(1), etc.? This has been driving me nuts for two days, and any help would really be appreciated. You can probably tell I'm new at this...
Thanks,
Brad

You need to create an Array variable. Also you should turn on Option Strict & Option Explicit to have the design environment show you some mistake you are making with not explicitly converting your values to the proper datatypes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.