Question:
Visual Basic Save variables?
?
2011-08-24 18:06:36 UTC
Hey, i have been at this for a while, so i have finally broke down and asked. I am making a video game in Visual basic for the first time. (I have made games before, just the first one in basic) I have searched and searched, but i cannot seem to find a way to save variables onto a external location.
Idk if that was the correct term, so i am gonna describe it.
------------
I am making a text-based game, so this is written in console, not forms.
I would like to save a group of variables onto a type of file. (I don't care what type)
Then, later when a player opens the game (console app), they can load the game.
the game loaded is just the player's stats. You know, name, strength, wisdom, Hp.
--------
I know this has to be possible. Can someone please help me, I would be incredibly thankful.
Thx for the help :)
Four answers:
anonymous
2011-08-24 18:14:10 UTC
Here's a great tutorial on how it all works in C#:



http://csharpfornoobs.blogspot.com/2011/06/file-readingwriting-and-list-boxes.html



In it there are links to relevant classes and namespaces (for file reading/writing) listed in the online MSDN Library. If you go to those links and click to view the Visual Basic source code instead of C# code, you will see that the syntax is only slightly different from what is shown in the tutorial.
anonymous
2011-08-24 18:09:57 UTC
Have you ever heard of reading and writing on vb if you write in a notepad all your stats you can read it into the console and the stats will be sabed you can look it on google or youtube they will have something
Wolfman
2011-08-24 18:14:51 UTC
look up text file read and file write in vb you can use these routines to store anything you want in txt or ini files and read them back into the variables at program startup and use them anyway you want
Don't sue me!
2011-08-24 18:16:11 UTC
If you're using the .net framework, then it's like this:



System.IO.File.WriteAllText()

System.IO.File.ReadAllText()



If VB6 or older, then see these pages:

http://dreamincode.net/forums/topic/29575-file-handling-in-visual-basic-6-part-1-sequential-files/

http://www.google.com/search?q=read+write+data+to+a+file+vb+6


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...