Prerequisites:
I've got:
- a
Collectioncalled "users" - which consits of instances of a
Classcalled "MatchClass" - the "
MatchClass" consists of only two properties -useridandmatchArray(plus some methods which are not relevant to the question)
What I want to do
Is to loop over the Collection, while simultaneously being able to
- access the position within the collection
- access the properties of the class instance
- find the highest value out of all
matchArrays (they are already sorted) and store theuserid
What I've tried so far:
To loop over the Collection with a For Each loop
Dim users as New Collection Dim i as Byte Dim max as Integer: max = 0 Dim maxuser as String ' users Collection is filled with instances of MatchClass ' ... skipping code to simplify ... Dim user as MatchClass For Each user in users temp = user.matchArray(0, 0) If temp > max Then max = temp maxuser = users.Item ' <- this won't work End If Next userThen I can't acess the position of the
userwithin theFor Eachloop
Alternatively I tried numerical looping:
For i = users.Count to 1 Step -1 users.Item(i).matchArray(0, 0) ' <- this won't work Next iThis unfortunately won't work either, as I can't access the properties of the
MatchClassinstances via theusers.Item(i)code either.
Is there perhaps a best of both worlds solution where I can do both? Feels like it should be somethign arbitrary that I'm just missing.