Jump to content

Save/Load Data?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
slovig

slovig

    Newbie

  • Members
  • Pip
  • 5 posts
Hey. I'm not so much "new" to VB, but I dont know much, just as much as I was taught in school. What I'm doing for a school project, is creating an application, that can save information, and close out, then open up again, and load the saved data. I'm not exactly sure what you would do. The application is basically a voting application, for a 3 night talent show.

Thanks!

#2
Chambered

Chambered

    Newbie

  • Members
  • PipPip
  • 11 posts
I'm working on a program right now and a feature I want is basically the same idea. To save a few options in a file so when the program restarts a user doesn't have to reset all their preferred options.

While I don't know if there's a "correct" way to do it, this is what I've considered doing (Using VisualStudio '05):

With a File stream (Import System.IO) save data to a text file in a specific format:

Dim UserOptions as String = "option1:on|option2:off|option3:off"

Dim Path As String = "C:\Options.txt"

Dim SaveOptions As New StreamWriter(New FileStream(Path, FileMode.Append, FileAccess.Write))

SaveOptions.WriteLine(UserOptions)

SaveOptions.Close()

then when the program loads, or whenever you want, load the text file into a variable and parse it apart.
Dim LoadOptions As String

Dim Path As String = "C:\Options.txt"

Dim ReadOptions As New StreamReader(New FileStream(Path, FileMode.Open, FileAccess.Read))

LoadOptions = ReadOptions.ReadToEnd

LogMessage.Close()

Then split up the resulting string LoadOptions to get the various user options.

Hope that helps (and was correct, I'm only a novice myself :o)

#3
slovig

slovig

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks. But I think I'm gonna step away from this. I've decided to let someone else create it.
[\.slovig./]