Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property bag Contents Method

Status
Not open for further replies.

MrMoocow

Programmer
May 19, 2001
380
0
0
US
Hello,
I've searched MSDN, no help. I've searched tek-tips. No Help. So I must post. Its very simple:
How do i use a properry bags contents method?

The object browser reveals nothing, creative use reveals nothing. I can't figure it out! Msdn saysthere is only 2 methods (read and write).

help is appreciated. Brad,
Hey! email me any time! Bradsvb@yahoo.com
 
The Contents property returns a byte array of the contents of the proprty bag - which can then be saved to a database or file. The purpose of this is to persist the state of an object (or any other data you can think of).

The Contents property can be set to a byte array which then restores the contents of the bag:

dim oPB as new PropertyBag
dim oNewPB as new PropertyBag
dim sPersist as String
dim arByte() as Byte

'set some values in the property bag
oPB.WriteProperty("Name", "fester")
oPB.WriteProperty("Title", "uncle")

'persist those values to a string
sPersist = oPB.Contents

'convert string to a byte array
arByte() = sPersist

'put the persisted data in a new property bag
oNewPB.Contents = arByte()

'the new property bag now has the values in it
debug.print oNewPB.ReadProperty("Name")
debug.print oNewPB.Readproperty("Title") -Chris Didion
Matrix Automation, MCP
 
Well I feel stupid, I was thinking this has got to be to look at the contents not read from and to them!. well i was off. Thanks for setting me straight. Is there anyway to look through all the different properties in the bag? Brad,
Hey! email me any time! Bradsvb@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top