PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2005 How to create a HALL OF FAME (High score) system?-VBForums
Results 1 to 11 of 11

Thread: How to create a HALL OF FAME (High score) system?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    22

    How to create a HALL OF FAME (High score) system?

    Yo!

    Im creating a quiz game although i was wondering if any one can teach/tell me how to create a high score system.

    For example when the user clicks say button1 (which is stop quiz) an input box will appear asking the user to input their name and then press okay. It then gets the current score from the text box (which is just an integer in a text box indicating how many they got right) and saves it to an Text file or something.

    and when the user goes back to the main menu, he/she can select "Hall of Fame" which then brings up the highscores (in a new form) of previous users scores.

    Now, i understand in order to this there will be two functions.

    1 will be write

    and the second will be read.

    I haven't dealt with text files before (or anything for that matter) so anything simple a noob will understand will be great

    Thanks
    guys

  2. #2
    Hyperactive Member Monkz's Avatar
    Join Date
    Aug 2009
    Posts
    304

    Re: How to create a HALL OF FAME (High score) system?

    There is lots of stuff that explains this if u search this up on google, though i am mostly familar in VB.6 where i did the same thing.

  3. #3
    Hyperactive Member Monkz's Avatar
    Join Date
    Aug 2009
    Posts
    304

    Re: How to create a HALL OF FAME (High score) system?

    I saw something like this though i dont exactly know if it works:

    The CreateText method creates a text file and returns a System.IO.StreamWriter object. With the StreamWriter object, you can then write to the file:

    Code:
    Code:
    Dim oFile as System.IO.File
    Dim oWrite as System.IO.StreamWriter
    oWrite = oFile.CreateText(“C:\sample.txt”)
    OpenTextThe OpenText method opens an existing text file for reading and returns a System.IO.StreamReader object. With the StreamReader object, you can then read the file:

    Code:
    Code:
    Dim oFile as System.IO.File
    Dim oRead as System.IO.StreamReader
    oRead = oFile.OpenText(“C:\sample.txt”)
    Writing to Textfile:

    Code:
    Code:
    oWrite.WriteLine(“Write a line to the file”)
    oWrite.WriteLine()         ‘Write a blank line to the file

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    22

    Re: How to create a HALL OF FAME (High score) system?

    Nope that didnt work monkz

    lol

  5. #5
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,958

    Re: How to create a HALL OF FAME (High score) system?

    Use XML, just create a new structure for that...

    <Hall Of Fame><User><Name>John Doe</Name><HS>1000</HS></USER>...

    And then you only need to get and set the values...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  6. #6
    Hyperactive Member Monkz's Avatar
    Join Date
    Aug 2009
    Posts
    304

    Re: How to create a HALL OF FAME (High score) system?

    Sorry then. I havent gotten into that yet. Im trying to learn VB.Net, but im working on a different type of project right now.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    22

    Re: How to create a HALL OF FAME (High score) system?

    bump

  8. #8
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,958

    Re: How to create a HALL OF FAME (High score) system?

    bump why?

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    22

    Re: How to create a HALL OF FAME (High score) system?

    well i was planning on just using a text file not so much xml

    lol

  10. #10
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,958

    Re: How to create a HALL OF FAME (High score) system?

    You can just save the user line like this:
    UserName;Score

    Little example
    VB.NET Code:
    1. 'Read the results from file
    2.         Dim strContent() As String = IO.File.ReadAllLines("PATH")
    3.         Dim dicScores As New System.Collections.Generic.Dictionary(Of String, Integer)
    4.         Dim userResult() As String
    5.         For Each strUser As String In strContent
    6.             userResult = strUser.Split(";")
    7.             dicScores.Add(userResult(0), Integer.Parse(userResult(1)))
    8.         Next
    9.  
    10.         'Return the result of someone
    11.         Dim result As Integer = dicScores("UserName")
    12.  
    13.         'Verify if the user exists
    14.         If dicScores.ContainsKey("UserName") Then
    15.             dicScores("UserName") = 1000 'Update the value
    16.         Else
    17.             dicScores.Add("UserName", 1000) 'Add a new one
    18.         End If
    19.  
    20.  
    21.         'Save the scores to the file
    22.         Dim strSave As String = String.Empty
    23.         For Each userScore As KeyValuePair(Of String, Integer) In dicScores
    24.             strSave &= userScore.Key & ";" & userScore.Value.ToString & vbNewLine
    25.         Next

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  11. #11
    Member
    Join Date
    Dec 2005
    Location
    Philadelphia
    Posts
    48

    Re: How to create a HALL OF FAME (High score) system?

    Could also you an ini file which would be more practical then just a text file.

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