• Log in or sign up for an account here: https://www.sythe.org/login

[Source]Sorting a ListView

Covey

Creator of EliteSwitch

Retired Sectional Moderator
Visual Basic Programmers
Joined
Sep 9, 2005
Sythe Gold
9
Messages
4,510
Age
17
Location
Fuckin' BAM!
I had to make a procedure to sort a listview, so if anyone else needs one you can edit this.
This was a custom function for a program i was making for cool372. It was required to sort the top 10 highscores with the format of "blah blah - 99:99:99".

Code:
Private Sub LoadnSortHighscores(lstListBox As ListBox, strPath As String)
    Dim fFile As Long, strData As String, i As Long, strLines() As String, a As Long
    fFile = FreeFile
    Open strPath For Input As fFile
        strData = Input(LOF(fFile), fFile)
    Close fFile
    strLines() = Split(strData, vbCrLf)
    Do Until lstListBox.ListCount >= 10
    For i = 0 To 9
        For a = 0 To 9
            If Not a = i Or Not Val(strLines(a)) = "0" Then
                If Not Val(Replace(Split(strLines(i), "-")(1), ":", "")) >= Val(Replace(Split(strLines(a), "-")(1), ":", "")) Then
                    GoTo SkipThis
                End If
            End If
        Next a
        If Not Val(Replace(Split(strLines(i), "-")(1), ":", "")) = "0" Then
            lstListBox.AddItem strLines(i)
        End If
        strLines(i) = "0-0"
SkipThis:
    Next i
    Loop
End Sub
 
Runescape Gamblingrunescape gambling
Back
Top