Link to home
Start Free TrialLog in
Avatar of andyakira
andyakira

asked on

how do i do this, Ranking System

I have a database of names and scores. Heres how the list looks like:


Andy|55
Blah2|66
LOL|12
Shane|221
Mike|923
Gloria|222


The list has around 2,000 names|scores.

how can i make it set each user a rank by the score they have, like this:

Mike:Rank 1
Gloria:Rank 2
Shane:Rank3
Blah2:Rank4
Andy:Rank5
LOL:Rank6.

i want to seach for user Andy and have it  show a rank of #5.


Avatar of AzraSound
AzraSound
Flag of United States of America image

If that's all you have to go by, I think youd have to do something like:


"SELECT * FROM myTable ORDER BY scores DESC"

Do
    i = i + 1
Loop Until recordset.Fields("name") = "Andy"

MsgBox "Rank = " & i
Avatar of andyakira
andyakira

ASKER

how does teh "SELECT * FROM  work?
is there another way of doing this without using sQL
You are using a database, but dont want to use any SQL?
im not familiar with it, where can i go to learn more about sql?
Avatar of Mike Tomlinson
Is your "database" just a text file?

If so, are we changing the file from this:

Andy|55
Blah2|66
LOL|12
Shane|221
Mike|923
Gloria|222

to this:

Mike:Rank 1
Gloria:Rank 2
Shane:Rank3
Blah2:Rank4
Andy:Rank5
LOL:Rank6

or do you want a second "database" text file containing this info?

Idle_Mind
The file is a txt file that contains names:scores, i'm not trying to convery anything. just trying to find the rank of the user based on their score.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Idle_Mind,
I'm getting a script out of range "ScoreL.AddItem Format(values(1), "000000000") & ", " & values(0)". do you know whats causing it
If a line in your text file is missing a "|" between the name and the score that could cause it.

Try changing your While...Wend loop to this and see if that fixes it:

        While Not EOF(1)
            Line Input #1, inputLine
            If Instr(inputLine, "|") > 0 Then
                values = Split(inputLine, "|")
                List1.AddItem Format(values(1), "000000000") & ", " & values(0)
            End If
        Wend

Idle_Mind
Thanks idle mind