Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gamechampionx

File Input / Output in VB6

This topic is 6083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m planning on making an RPG, but I can''t make it save. I don''t know how to use file input and output. Could someone explain it to me, and maybe give an example, or reccomend a book to buy?

Share this post


Link to post
Share on other sites
Advertisement
  

Dim strCharactername as String
Dim intHealth as Integer

Public Sub SaveGame(strFilename as String)

Open strFilename For Output as #1

Print #1, strChractername
Print #1, intHealth

'' Etc, etc

Close #1
End Sub


Public Sub LoadGame(strFilename as String)

Open strFilename For Input as #1

Line Input #1, strCharactername
Line Input #1, intHealth

'' Etc etc

Close #1

End Sub

End Sub


Oli



All the best problems start with C

.:: K o s m o s E n g i n e ::.

Share this post


Link to post
Share on other sites
Thanks a lot. I''ll use this to make savegames. However, I need help with something else. I need to test if a file with a certain name is present in the same directory as the exe file is. Any help is appreciated. Thanks again!

Share this post


Link to post
Share on other sites
Alternately you can use the Dir function:

If Len(Dir(App.Path & "\temp.bmp")) > 0 Then
'file exists
MsgBox "Yes"
Else
'file doesn't exist
MsgBox "No"
End If


Breakaway Games

Edited by - Machaira on February 23, 2002 12:23:41 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!