dcsimg
Results 1 to 3 of 3

Thread: guys help me problem with conditions im a noob!!!

  1. #1

    Thread Starter
    Member rsalumpit's Avatar
    Join Date
    Jan 2008
    Posts
    56

    guys help me problem with conditions im a noob!!!

    im making school project its a puzzle game i need help with the condition of the score i want to delete the lowest score when it a new score beats the lowest i have 3 places in my database..

    for example:
    1st 100pts
    2nd 90 pts
    3rd 60 pts

    and when a new score recorded i want to replace the 3rd place if he gots like 70pts. i know its a matter of less than greater than only but im so mentally blocked now..huhu can any one figure this out please im using vb6...pleasse help me

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: guys help me problem with conditions im a noob!!!

    Start by comparing the new score to the current high score, followed by the rest in order. If the new score is greater than the score it's being compared to then shift everything from that point one along and replace with the new score. I would not write to a database until the unload event
    VB6 code
    Code:
    Option Explicit
    Dim HiScores(4) As Long
    
    Private Sub Command1_Click()
         AddNewScore Rnd * 1000
    End Sub
    
    Private Sub AddNewScore(ByVal Score As Long)
    Dim i As Long, ii As Long
        For i = 0 To UBound(HiScores)
            If Score > HiScores(i) Then
                For ii = UBound(HiScores) - 1 To i Step -1
                    HiScores(ii + 1) = HiScores(ii)
                Next ii
                HiScores(i) = Score
                Exit For
            End If
        Next i
        ShowScores
    End Sub
    
    Private Sub ShowScores()
    Dim i As Long
        Debug.Print "__________________"
        For i = 0 To UBound(HiScores)
            Debug.Print (i + 1) & ") " & HiScores(i)
        Next i
    End Sub

  3. #3

    Thread Starter
    Member rsalumpit's Avatar
    Join Date
    Jan 2008
    Posts
    56

    Re: guys help me problem with conditions im a noob!!!

    thnx ill try this

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width