Question Running total score in VS 2008

jme2365

New member
Joined
Nov 19, 2008
Messages
1
Programming Experience
1-3
I am trying to keep a running score in my applicationwith the following coding:
VB.NET:
 PlayerScore = CInt(Val(lblPlayerPoints.Text))

 PlayerScore = PlayerScore + CInt(Val(lblPlayer(PScoreIndex).Text))

  PScoreIndex += 1

PlayerScore is how many points the players has got.

lblPlayerPoints is where the PlayerScore is shown

PScoreIndex is set so that it chooses the next lblPlayer number when a new card is displayed and a new value shown


However the (lblPlayer( text is giving me the following error.
Error 1 Class 'System.Windows.Forms.Label' cannot be indexed because it has no default property.

Does anyone have any ideas. Do i need some kind of declaration?
 
That's because you're trying to use a label as an array, which you can't do control arrays in the designer.

What you should be doing is storing each score in a List (Of Integer) then you could simply loop through it like so:
VB.NET:
For Counter As Integer = 0I To YourScoresList.Count - 1I
  PlayerScore += YourScoresList(Counter)
Next Counter
 
Back
Top