CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2002
    Location
    sydney, australia
    Posts
    36

    Question Help With Saving Files Please!!

    HI,

    I have made a program that is like a tamagotchi. you have a choice of ten different pets. Now what i want it to do is save the pet stats and the pet name and picture.

    This si what i had before, but it wont work because then you can only save one pet at a time.

    On Error GoTo fileerror
    Open "savedpet.sp" For Output As #1
    Print #1, weight; health; happy; hunger; lke; dis; age; Form2.petpic; Form2.pet
    Close #1
    Exit Sub
    fileerror:
    MsgBox "Error saving pet", vbCritical


    The words on the print line are variables with numbers.

    I need to know how to save it, but so one of those boxes appear and asks you where to put the file and specify a file name too.

    Also do this for load so the user can choose which pet to load.

    Thanx alot for the help all.
    Im only a beginner! So plz be willing to help me!

    A good site 4 vb source code: www.a1vbcode.com

    cya ;-)

  2. #2
    Join Date
    Sep 2002
    Location
    sydney, australia
    Posts
    36

    ALSO

    ALso,

    Would i have to insert the COMDLG32.OCX to do this???

    Thanx.
    Im only a beginner! So plz be willing to help me!

    A good site 4 vb source code: www.a1vbcode.com

    cya ;-)

  3. #3
    Join Date
    Sep 2002
    Location
    sydney, australia
    Posts
    36

    ALSO2

    Is there a way to set a default directory??

    Say, where the app was installed??(like; app.path & ("\saved"))

    Thanx again.
    Im only a beginner! So plz be willing to help me!

    A good site 4 vb source code: www.a1vbcode.com

    cya ;-)

  4. #4
    Join Date
    Dec 2002
    Location
    India
    Posts
    76
    There is no need to COMDLG32.OCX for this..


    ur code is fine and to add multiple times i hope u can loop thru the required no of times the PRINT Statment in ur code.


    U Can set the default directory in a roundabout way as follows

    Dim strFileName As String

    strFileName = App.Path &
    "<predefined FolderName>\<predefined FileName>"

    Open strFileName For Append As #1

  5. #5
    Join Date
    Sep 2002
    Location
    sydney, australia
    Posts
    36

    Thanks but....

    but what i want is for a dialog box to come up and ask you where to save and the filename, etc.

    SO they can save more than one file at a time.

    Like when you would save a document in word. I have seen them b4 in vb projects.

    Thanx anyway.
    Im only a beginner! So plz be willing to help me!

    A good site 4 vb source code: www.a1vbcode.com

    cya ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured