Converting High score table to a low score table

Discussion in 'Visual Basic ( VB )' started by jjohall2000, Mar 16, 2007.

  1. jjohall2000

    jjohall2000 New Member

    Joined:
    Mar 16, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    If Int(PlayerScore) > intscore(x) Then
    just change this to
    If Int(PlayerScore) < intscore(x) Then
     
  3. jjohall2000

    jjohall2000 New Member

    Joined:
    Mar 16, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for that but is dose not work
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice