-
Jan 27th, 2008, 10:34 AM
#1
Thread Starter
Member
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
-
Jan 27th, 2008, 11:01 AM
#2
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
-
Jan 27th, 2008, 11:13 AM
#3
Thread Starter
Member
Re: guys help me problem with conditions im a noob!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|