Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

High Scores Table

Status
Not open for further replies.

Juggalatas

Programmer
Jun 6, 2005
6
US
Ok, so I took it upon myself to work on some cheesy games after I got out of my vb class, but I have run into a small problem. I do not have the slightest idea as to how to make a high scores table, what I got so far is a variable that creates an input box when u finish the game for your name, and I use add item to add the score and variable with the name to 2 seperate list boxes. I know this is unconventional and it doesn't work, I want to make this look more profesional, I have read all kinds of code on saving and loading high scores too, but they all speak giberish, can someone please explain to me some of this in "stupid" terms?
 
If you want the scores to persist between gaming sessions then you'll need some way to save them to disk.

You could use the SaveSetting and GetSetting function to read and write them to the registry. You could use ADO to save them in a database. You could also use ADO to make a recordset and then persist it to disk. You could use Get/Put or Write/Input to save the scores in a file file. You could use the Win32 API to make an INI file using functions like GetPrivateProfileString and WritePrivateProfileString. There are so many more...
 
ahhh, ya see, you totally didn't translate that into stupid...But ill look into it, thanks ;)
 
rezzij, your a wonderful person you know that? Thanks for dumbing it down for me
 
Ok those helped me, and I got some other info, now I can load a ton of saves in my box, but I cant save several entries, could anyone lend a hand? This is how I currently save, and then how I load

Code:
    fname = frmMain.fname + frmLevel_Two.fname
    score = frmMain.score + frmLevel_Two.score
    
    Dim f As Integer, pass As String
    f = FreeFile
    Open App.Path & "\highscores2.txt" For Output As f
    Write #f, fname, score
    Close #f

And the Load code
Code:
Dim f As Integer, pass As String
        f = FreeFile
        Open App.Path & "\highscores.txt" For Input As f
        Do While Not EOF(f)
        Input #f, fname, score
        lstName.AddItem fname
        lstScores.AddItem score
        Loop
        Close #f
 
In your save routine, just change "Open App.Path & "\highscores2.txt" For Output As f" to "Open App.Path & "\highscores2.txt" For APPEND As f"

Opening a file for Output will overwrite the existing file everytime.

Alan

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Thanks alot Alan, lol I fixed it last night, did a bit more research, it was hidden in some source code for a random number generator lol
 
Unless this forum is going to be used for reference, it should be deleted so that my remedial questions aren't spamming the forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top