Okay, so I'm trying to sort two arrays simultaneously. One that keeps track of the score, and one for the name.
I have the complete code to sort the score by descending size. MyArray is for score, and MyArray2 is for the names.
That means that the one who got the score MyArray(0) has the name; MyArray2(0), and so on.
How can I after sorting, get the names to follow the score? If you know what I mean..
Code:Dim iOuter As Long Dim iInner As Long Dim iLBound As Long Dim iUBound As Long Dim iTemp As Long Dim iMax As Long Dim MyArray() As String Dim MyString As String Dim MyArray2() As String Dim MyString2 As String Dim FF2 As Integer Dim FF As Integer Private Sub Command1_Click() For i = LBound(MyArray) To UBound(MyArray) List1.AddItem (MyArray(i)) Next End Sub Private Sub Form_load() FF = FreeFile() Open ("C:\Documents and Settings\Administratör.MATRIX\Mina dokument\Score.txt") For Binary As FF MyString = Space(LOF(FF)) Get FF, , MyString Close FF FF2 = FreeFile() Open ("C:\Documents and Settings\Administratör.MATRIX\Mina dokument\Name.txt") For Binary As FF2 MyString2 = Space(LOF(FF2)) Get FF2, , MyString2 Close FF2 MyString = Left(MyString, Len(MyString) - 1) MyString2 = Left(MyString2, Len(MyString2) - 1) MyArray = Split(MyString, ",") MyArray2 = Split(MyString2, ",") iLBound = LBound(MyArray) iUBound = UBound(MyArray) For iOuter = iUBound To iLBound + 1 Step -1 iMax = 0 For iInner = iLBound To iOuter If CLng(MyArray(iInner)) < CLng(MyArray(iMax)) Then iMax = iInner Next iInner iTemp = MyArray(iMax) MyArray(iMax) = MyArray(iOuter) MyArray(iOuter) = iTemp Next iOuter For i = LBound(MyArray) To UBound(MyArray) MyArray(i) = Format(MyArray(i), "#,##") List1.AddItem (MyArray(i)) Next End Sub




Reply With Quote