2D Arrays with a record.
I have a seemingly simple but not so simple problem i need to solve for the highscores element of my programming assignment (game). I have seven difficulty levels, each one with its own table of highscores. The highscores are in a record like so:
Public Type highscores
name As String
score As Long
End Type
And the array of highscores is declared as:
Public hscores(1 To 21) As highscores
Where there are 20 names and one more is being added to the end for sorting.
The question is, how can i implement an array of 0 to 6 (6 different difficulty levels) - to contain the array of records - in VB6?
I don't think this is the right answer:
Public hscores(0 to 6, 1 to 21) as highscores
but i cant do this either (wrong code):
Public diffhs(0 To 6) as hscores(1 to 21)
Any ideas?
Thanks
tenpoints
[922 byte] By [
tenpoints] at [2007-11-11 8:44:36]

# 1 Re: 2D Arrays with a record.
Hi,
here's an example to use a multidimensional array, perhaps it helps:
Dim tblHscores(100,2) as string
tblHscores(0,0) = "Jack" 'Name player
tblHscores(0,1) = "L1" 'Level player
tblHscores(0,2) = "100" 'Score player
tblHscores(1,0) = "Sam"
tblHscores(1,1) = "L2"
tblHscores(1,2) = "200"
You can loop through the array and filter the data for ex all scores level2.
Or you can always use 1 table for each level, but 1 table should do.
# 2 Re: 2D Arrays with a record.
Ohh right, so you'd allocate three values of the 2nd dimension to the player data, then to find the level you'd search for "L2" and get all the data associated with that. It sounds messy, but it could work.
I shall test it out.
Another method I thought might work would be to just have seven different arrays (hscoresdiff0(1 to 21), hscoresdiff1(1 to 21)... etc) and allocate them manually.
Thanks for your reply.
Tenpoints
# 3 Re: 2D Arrays with a record.
Try what's the best solution for you. If you can sort the table, the search for scores will be more easy and faster, but I think you won't notice it in the speed of transaction :)