Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Visual Basic - how do i save details from a form

  • 12-12-2004 02:33PM
    #1
    Registered Users, Registered Users 2 Posts: 36


    Here is what i want to do, in Visual Basic 6, i am making a game... it is a kind of Sim City game where there are loads of numbers going up and down and all this kind of thing... i can do all that fine.

    Problem is the following, lets say someone plays my game, but want to then save their progress and come back to it later, i need to be able to read their statistics from a data file of some sort...

    I know i'm asking alot here, but how do i set up this file? How do i write details to, and read details to and from a form

    thanks in advance


Comments

  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    You could look into ini files, it's proberly better then a txt file for future proofing later versions of the program.
    (some people might say use the registry, but I feel this affects portability of the program)

    I've just done a quick google and come up with: http://www.officecomputertraining.com/vbtutorial/tutpages/page40.asp

    You'll prob need to look through a few.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    If its a sim-city type game I'd imagine there's a lot to save. Would you not write the detail to a database?


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    I know i'm asking alot here, but how do i set up this file?

    Look up any and all fo the following:

    1) DAO, RDO, ADO, and other database-access techniques
    2) Registry I/O
    3) Ini-file I/O
    4) File I/O
    How do i write details to, and read details to and from a form
    Same way as you read/write details from/to a form when you're not saving to file. If you've got your game working, you're almost definitely already reading from and writing to a form.

    jc


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    have a look at XML as well
    might be handy


  • Registered Users, Registered Users 2 Posts: 36 utilitarian


    that is cool, however, what i want to know is what do i write... i will look into the things that you told me to but is there not some "write C:\MyFolder\data.dat" that i can do?


  • Advertisement
  • Closed Accounts Posts: 13 But


    This might be useful for simple reading and writing to a .dat file or whatever you like.

    http://forums.aspfree.com/showthread.php?p=118578


  • Closed Accounts Posts: 54 ✭✭charlo_b


    Simple file I/O in VB:



    'Writing to a file
    dim iFreefile as integer
    iFreeFile = freefile



    Open "C:\test.txt" For Output As #iFreeFile
    Print #iFreeFile, "This is the sample text"
    Close #iFreeFile

    'Reading from a file
    dim iFreefile as integer
    dim sInput as string
    iFreeFile = freefile

    Open "C:\test.txt" For Input As #iFreeFile
    Line Input #iFreeFile , sInput
    close #iFreeFile


    Use For Output for creating new/overwriting file
    Use For Append for creating new/adding to a file
    Other options are also available but this should get you going


Advertisement