Alpagut
Alpagut

Reputation: 1173

Save variables, collections, in vb.net

How can I save variables, collections, dictionaries in vb.net so that after the user restart the software the modifications will be saved.

for Example through a textbox the user enters a new/old key and a value that changes a dictionary. After he restarts when he checks back the previously entered key, his modifications are permanent.

Upvotes: 1

Views: 3221

Answers (2)

Naqeeb
Naqeeb

Reputation: 49

Ok, I used to ask the same question, seeing that you sound like an absolute beginner, I'll go easy.

Click Project on the top of the screen and scroll down to your program's properties. In my case it was Personal Assistant properties... enter image description here Now click on the highlighted text, Settings enter image description here You should see a menu like this, now you can make new settings here. These are like variables but stay like that even when the program is restarted. In my case, I made one called Name for the program to remember the user's name.

If you want to use the setting, type This in: My.Settings.[Name of setting] If you want to change it just put an equal sign after it and type in its new value. My.Settings.[Name of setting] = [New Value]

Here is an example: Label1.Text = "Hello " + My.Settings.Name + "!"

Upvotes: 3

L-Four
L-Four

Reputation: 13531

I assume you are talking about a client application that stores this data locally? In that case isolated storage is a possibility, see http://www.codeproject.com/Articles/6535/Isolated-Storage-in-NET-to-store-application-data. Or you could have a local database based on SQLite to store these kinds of things.

You can also choose to store this data centrally. But we don't know your exact requirements/restrictions, you might want to give us some more information.

Upvotes: 2

Related Questions