Results 1 to 5 of 5

Thread: [Resolved][Help] Rank/sort a number

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    33

    Resolved [Resolved][Help] Rank/sort a number

    Hello everyone, i'm stuck with this.
    i try to find fastest way, but its only fits for certain sequence of number

    here is what i want:

    Points Ranks
    10 5
    25 4
    38 3
    35 2
    90 1

    assuming that all points is on a label named lblTotPts(0 to 4)
    and all Ranks is on a label named lblRank(0 to 4)

    im using this code
    Code:
        Dim PM
        For x = 1 To 5
            For i = 1 To 5 - 1
                If lblRank(i).Caption = "" Then
                    If Val(lblTotPts(i).Caption) > Val(lblTotPts(PM).Caption) Then
                        PM = i
                    End If
                End If
            Next
            lblRank(PM).Caption = x
            PM = 0
        Next
    it works only on some sequence of number. but its returned like this, if the first number was on rank 5.

    Points Ranks
    5 5
    4
    3
    2
    1

    as i change the ">" sign to "<" it works for that sequence, but not for this:

    Points Ranks
    1 5
    2
    3
    4
    5

    so, how to do that using a fast way (looping) because the actual element (lblRank and lblTotPts) on my project is not only contains 5 controls.

    thanks before
    Last edited by astralist; Sep 3rd, 2011 at 10:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width