Hjælp til highscore

Tags:    visual-basic

Jeg har lavet en highscore. Men jeg har det problem at jeg kan vil have at ens navn også kommer på highscoren. Min kode ser sådan her ud:

Public Sub Highscore()
For I = 1 To 10
If Val(lblScore.Caption) > Val(txtHigh(I)) Then
U = I - 1
If Not txtHigh(U) = "Score:" Then
txtHigh(U) = txtHigh(I)
txtHigh(I) = lblScore
Else
txtHigh(I) = lblScore
End If
End If
Next I
endGame
End Sub

Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Highscore", 1, txtHigh(1)
SaveSetting App.Title, "Highscore", 2, txtHigh(2)
SaveSetting App.Title, "Highscore", 3, txtHigh(3)
SaveSetting App.Title, "Highscore", 4, txtHigh(4)
SaveSetting App.Title, "Highscore", 5, txtHigh(5)
SaveSetting App.Title, "Highscore", 6, txtHigh(6)
SaveSetting App.Title, "Highscore", 7, txtHigh(7)
SaveSetting App.Title, "Highscore", 8, txtHigh(8)
SaveSetting App.Title, "Highscore", 9, txtHigh(9)
SaveSetting App.Title, "Highscore", 10, txtHigh(10)
End Sub

Private Sub Form_Load()
score = 0
Randomize
thisNum = Int(12 * Rnd + 1)
lastNum = thisNum
Label1.Caption = thisNum
picImage.Picture = imglstBilleder.ListImages("pic" & thisNum).Picture
txtHigh(10) = GetSetting(App.Title, "Highscore", "10", "0")
txtHigh(9) = GetSetting(App.Title, "Highscore", "9", "0")
txtHigh(8) = GetSetting(App.Title, "Highscore", "8", "0")
txtHigh(7) = GetSetting(App.Title, "Highscore", "7", "0")
txtHigh(6) = GetSetting(App.Title, "Highscore", "6", "0")
txtHigh(5) = GetSetting(App.Title, "Highscore", "5", "0")
txtHigh(4) = GetSetting(App.Title, "Highscore", "4", "0")
txtHigh(3) = GetSetting(App.Title, "Highscore", "3", "0")
txtHigh(2) = GetSetting(App.Title, "Highscore", "2", "0")
txtHigh(1) = GetSetting(App.Title, "Highscore", "1", "0")
End Sub

Hvordan kan jeg få lavet så man også får sit navn på highscoren? Navnet skal stå i en anden label eller txtbiks end hvad pointene gør.......
Jeg vil gerne have et svar hurtigst muligt..

Takker på forhånd



2 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 5 karma
Sorter efter stemmer Sorter efter dato
Jeg har lavet en highscore. Men jeg har det problem at jeg kan vil have at ens navn også kommer på highscoren. Min kode ser sådan her ud:

<pre>
Public Sub Highscore()
For I = 1 To 10
If Val(lblScore.Caption) > Val(txtHigh(I)) Then
U = I - 1
If Not txtHigh(U) = "Score:" Then
txtHigh(U) = txtHigh(I)
txtHigh(I) = lblScore
Else
txtHigh(I) = lblScore
End If
End If
Next I
endGame
End Sub

Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Highscore", 1, txtHigh(1)
SaveSetting App.Title, "Highscore", 2, txtHigh(2)
SaveSetting App.Title, "Highscore", 3, txtHigh(3)
SaveSetting App.Title, "Highscore", 4, txtHigh(4)
SaveSetting App.Title, "Highscore", 5, txtHigh(5)
SaveSetting App.Title, "Highscore", 6, txtHigh(6)
SaveSetting App.Title, "Highscore", 7, txtHigh(7)
SaveSetting App.Title, "Highscore", 8, txtHigh(8)
SaveSetting App.Title, "Highscore", 9, txtHigh(9)
SaveSetting App.Title, "Highscore", 10, txtHigh(10)
End Sub

Private Sub Form_Load()
score = 0
Randomize
thisNum = Int(12 * Rnd + 1)
lastNum = thisNum
Label1.Caption = thisNum
picImage.Picture = imglstBilleder.ListImages("pic" & thisNum).Picture
txtHigh(10) = GetSetting(App.Title, "Highscore", "10", "0")
txtHigh(9) = GetSetting(App.Title, "Highscore", "9", "0")
txtHigh(8) = GetSetting(App.Title, "Highscore", "8", "0")
txtHigh(7) = GetSetting(App.Title, "Highscore", "7", "0")
txtHigh(6) = GetSetting(App.Title, "Highscore", "6", "0")
txtHigh(5) = GetSetting(App.Title, "Highscore", "5", "0")
txtHigh(4) = GetSetting(App.Title, "Highscore", "4", "0")
txtHigh(3) = GetSetting(App.Title, "Highscore", "3", "0")
txtHigh(2) = GetSetting(App.Title, "Highscore", "2", "0")
txtHigh(1) = GetSetting(App.Title, "Highscore", "1", "0")
End Sub
</pre>

Hvordan kan jeg få lavet så man også får sit navn på highscoren? Navnet skal stå i en anden label eller txtbiks end hvad pointene gør.......
Jeg vil gerne have et svar hurtigst muligt..

Takker på forhånd


Tilføj textboxe til navnene og kald dem txtHighName
Prøv sådan:
<pre>
Public Sub Highscore()
For I = 1 To 10
If Val(lblScore.Caption) > Val(txtHigh(I)) Then
U = I - 1
If Not txtHigh(U) = "Score:" Then
txtHigh(U) = txtHigh(I)
txtHigh(I) = lblScore
Else
txtHigh(I) = lblScore
End If
End If
Next I
endGame
End Sub

Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.Title, "Highscore", 1, txtHigh(1)
SaveSetting App.Title, "Highscore", 2, txtHigh(2)
SaveSetting App.Title, "Highscore", 3, txtHigh(3)
SaveSetting App.Title, "Highscore", 4, txtHigh(4)
SaveSetting App.Title, "Highscore", 5, txtHigh(5)
SaveSetting App.Title, "Highscore", 6, txtHigh(6)
SaveSetting App.Title, "Highscore", 7, txtHigh(7)
SaveSetting App.Title, "Highscore", 8, txtHigh(8)
SaveSetting App.Title
, "Highscore", 9, txtHigh(9)
SaveSetting App.Title, "Highscore", 10, txtHigh(10)

'Her har jeg tilføjet
SaveSetting App.Title, "HighscoreName", 1, txtHighName(1)
SaveSetting App.Title, "HighscoreName", 2, txtHighName(2)
SaveSetting App.Title, "HighscoreName", 3, txtHighName(3)
SaveSetting App.Title, "HighscoreName", 4, txtHighName(4)
SaveSetting App.Title, "HighscoreName", 5, txtHighName(5)
SaveSetting App.Title, "HighscoreName", 6, txtHighName(6)
SaveSetting App.Title, "HighscoreName", 7, txtHighName(7)
SaveSetting App.Title, "HighscoreName", 8, txtHighName(8)
SaveSetting App.Title, "HighscoreName", 9, txtHighName(9)
SaveSetting App.Title, "HighscoreName", 10, txtHighName(10)
End Sub

Private Sub Form_Load()
score = 0
Randomize
thisNum = Int(12 * Rnd + 1)
lastNum = thisNum
Label1.Caption = thisNum
picImage.Picture = imglstBilleder.ListImages("pic" & thisNum).Picture
txtHigh(10) = GetSetting(App.Title, "Highscore", "10", "0")
txtHigh(9) = GetSetting(App.Title, "Highscore", "9", "0")
txtHigh(8) = GetSetting(App.Title, "Highscore", "8", "0")
txtHigh(7) = GetSetting(App.Title, "Highscore", "7", "0")
txtHigh(6) = GetSetting(App.Title, "Highscore", "6", "0")
txtHigh(5) = GetSetting(App.Title, "Highscore", "5", "0")
txtHigh(4) = GetSetting(App.Title, "Highscore", "4", "0")
txtHigh(3) = GetSetting(App.Title, "Highscore", "3", "0")
txtHigh(2) = GetSetting(App.Title, "Highscore", "2", "0")
txtHigh(1) = GetSetting(App.Title, "Highscore", "1", "0")

' Her har jeg tilføjet
txtHighName(10) = GetSetting(App.Title, "HighscoreName", "10", "")
txtHighName(9) = GetSetting(App.Title, "HighscoreName", "9", "")
txtHighName(8) = GetSetting(App.Title, "HighscoreName", "8", "")
txtHighName(7) = GetSetting(App.Title, "HighscoreName", "7", "")
txtHighName(6) = GetSetting(App.Title, "HighscoreName", "6", "")
txtHighName(5) = GetSetting(App.Title, "HighscoreName", "5", "")
txtHighName(4) = GetSetting(App.Title, "HighscoreName", "4", "")
txtHighName(3) = GetSetting(App.Title, "HighscoreName", "3", "")
txtHighName(2) = GetSetting(App.Title, "HighscoreName", "2", "")
txtHighName(1) = GetSetting(App.Title, "HighscoreName", "1", "")

End Sub
</pre>

I Am The Cyborg, and i\\'m here to serve :)



Jeg har lavet en highscore. Men jeg har det problem at jeg kan vil have at ens navn også kommer på highscoren.


Er det ikke bare at gøre det samme som du har gjort med scoren, bare lave en label/text, som heddder navn og så hver gang du gør et eller andet med scoren, så gøre det samme med navnet.

Ellers må du lige omformulere dit spørgsmål.
Trøv



t