0

Ok so I am creating this scoring game using motorsport drivers.

The scores are in variables for example score.vettel is vettels score for the current gameweek.

A player has 6 drivers d1,d2,d3,d4,d5,d6 which are in the variable player(x).d1 where x is the player number. Maxsize is the number of players I have (so it loops from the first user to the last)

For x = 1 To Maxsize
If player(x).d1 = "VETTEL"
Then player(x).score = player(x).score + score.vettel
End If
Next

Of course I would have to do this loop for all drivers in all driver slots (d1,d2,d3,d4...)

For x = 1 To Maxsize
If player(x).d2 = "VETTEL"
Then player(x).score = player(x).score + score.vettel
End If
Next

Is there any way to make it so that I do not have to write all of this code but shorten it to something like:

For x = 1 To Maxsize
If player(x).d1 - player(x).d6 = "VETTEL"
Then player(x).score = player(x).score + score.vettel
End If
Next

Many thanks

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by djjavo
1

Maybe you could use an arraylist (drivers in the example below) instead of 6 different variables (d1 - d6). Then you could do something like this.

If player(x).drivers.Contains("VETTEL") Then
  player(x).score += score.vettel
End If
Votes + Comments
quite helpful:)
0

Sorry I didn't realise I made this post. Thanks anyway, its works well. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.