我有以下代码:
Private Sub highscoreCheck()
Dim a As Integer, b As String, c As Integer
For a = 1 To 10
If highscore > lst_score(a) Then
highscoreIndex = a
Exit For
End If
Next
If highscoreIndex > 0 Then
For highscoreIndex As Integer = 1 To 10
b = lst_name(highscoreIndex)
c = lst_score(highscoreIndex)
If highscoreIndex = a Then
lst_name(highscoreIndex) = userName
lst_score(highscoreIndex) = highscore
Else
lst_name(highscoreIndex) = b
lst_score(highscoreIndex) = c
End If
Next
End If
End Sub
我有一个由 10 行组成的高分列表,highscoreindex 代表当前高分是否大于任何高分,如果是,那么 highscoreIndex 是其中最高分。(如:12、8、6。而当前是9,那么highscoreindex是2)。我想要代码做的是将当前的高分插入到正确的位置,并使其下方的高分和它替换的高分下降。它确实插入了当前的高分,但不会让其他人下降,我搞砸了什么?我应该怎么办?