Recalling UserControl Properties
Standard controls have properties you can set using the object browser. The next time you bring up your VB program for editing you need to be able to recall the state of these settings. Example #3 on this page shows how to use a PropertyBag to remember these settings.
- VB property bag explained
- VB property bag example 2 with source code – general usage for parameter storage
Storage to the Bag
Save to the Bag – Fill up the object to be saved to disk | Stuff it in the Bag – The actual file operation to put on disk |
Private Sub cmdSave_Click() Dim objBag As New PropertyBag With objBag SaveBagContents .Contents, App.Path & "\Things.bag" End Sub
|
Private Sub SaveBagContents(Contents As Variant, FilePath As String) Dim FileNum As Integer FileNum = FileSystem.FreeFile() Open FilePath For Binary As FileNum End Sub
|
Retrieval from the Bag
Recall the Bag contents from disk | Dump the Bag – The actual file operation to get contents from disk |
Private Sub cmdLoadBag_Click() Dim objBag As New PropertyBag With objBag End Sub
|
Private Function LoadBagContents(FilePath As String) As Variant Dim FileNum As Integer FileNum = FileSystem.FreeFile() Open FilePath For Binary As FileNum LoadBagContents = tempContents
|
0 Comments