Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Converting High score table to a low score table (http://www.go4expert.com/forums/converting-score-table-low-score-table-t3444/)

jjohall2000 16Mar2007 21:36

Converting High score table to a low score table
 
Hi,

I have a sub which checks for the highest score and moves the name and score up or down depending on the position for example,

1. test 100
2. test1 99
3 test2 79
4.test3 10

Please can somebody help me convert it to do the opposite or suggest some new code. So the opposite would be,

1. test3 10
2. test2 79
3. test1 99
4. test 100

Many thanks in advance, the orignal code is posted below

Code:

Private Sub MoveDown()
    Dim PlayerScore As String, PlayerName As String, x As Integer
   
    PlayerScore = Int(txtaddscore.Text)
    PlayerName = txtaddname.Text
   
    If PlayerScore > intscore(9) Then    'If score is higher than lowest (Number 9) score
        MsgBox "Congratulations you got a high score", vbInformation, "Top Ten"
        For x = 0 To 9
            If Int(PlayerScore) > intscore(x) Then
                intnewpos = x      'Find highcores position
                Exit For
            End If
        Next x
        For x = 9 To intnewpos + 1 Step -1
            strnames(x) = strnames(x - 1)    'move names down
            intscore(x) = intscore(x - 1)  'move scores down
        Next x
        strnames(intnewpos) = PlayerName      'Give current name its position
        intscore(intnewpos) = PlayerScore    'Give current score its position


pradeep 17Mar2007 11:24

Re: Converting High score table to a low score table
 
If Int(PlayerScore) > intscore(x) Then
just change this to
If Int(PlayerScore) < intscore(x) Then

jjohall2000 17Mar2007 19:04

Re: Converting High score table to a low score table
 
Thanks for that but is dose not work


All times are GMT +5.5. The time now is 15:13.