user3295995
user3295995

Reputation: 21

What is the equivalent in VB.Net for saving settings in a VB6 PropertyBag?

I am migrating an application from vb6 to vb.net.

The application has some checkboxes and dropdowns whose values we can store in a file. For this it uses propertybag writeproperties to return a variant which is then written to a file by file put.

Similarly for loading the settings the file is loaded using file get and a variant is passed. the property bag content is then loaded using the variant and the properties are set.

**application code:**
dim bytarray() as byte
bytArray = mOptions.State
**usercontrol code:**
Public Property Get State() As Variant
Dim pb As New PropertyBag
With pb
.WriteProperty "property1", m_property1
.WriteProperty "property2", m_property2
.WriteProperty "property3", m_property3
State = .Contents
End With
End Property 

What will be the right way to do this in vb.net? I have to use the previously saved files as well.

Thanks.

Upvotes: 2

Views: 1184

Answers (2)

Joel Coehoorn
Joel Coehoorn

Reputation: 415880

Take a look at My.Settings. You must define the properties you want in the project settings in Visual Studio, but what you end up with is much more portable, and ultimately easier to work with.

Upvotes: 0

Mych
Mych

Reputation: 2553

How long is a piece of string... There are many ways of doing this and it all depends on what the data is used for. If its just to save the checkbox setting while the works on the page/form then the viewstate will handle this. If you are just passing values to another page/form then context, cookies, sessions could be used. If the information needs to be remembered for when the user comes back to the site/app then again cookies or bringing the data back from a db/file having saved them on leaving page/form.

Upvotes: 0

Related Questions