PropertyBag Changes in Visual Basic .NET
In Visual Basic 6.0, the PropertyBag object was used to persist an object's data between instances, allowing you to store values and retrieve them the next time the object was instantiated. Although you could set an object's properties to a default value at design time, any values entered at run time were lost when the object was destroyed. The PropertyBag object allowed a copy of the object to be persisted in a binary format and retrieved for later reuse. For example, a class used to calculate loans might use a PropertyBag object to persist an interest rate between instances, rather than entering it each time the class is used.
In Visual Basic .NET, the PropertyBag object no longer exists, but you can still persist an object's data using the System.Runtime.Serialization and System.IO namespaces. In addition to persisting an object in binary format, you can also persist an object in a SOAP format.
To persist an object in Visual Basic .NET, you first mark the class as Serializable. When instantiating the object, you use a Stream class and a BinaryFormatter or SoapFormatter class to retrieve the object's data from a file. Before destroying the object, you again use the Stream and formatter classes to write the object's values to the file.
For an example of how to persist an object, see Walkthrough: Persisting an Object.