CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 1999
    Posts
    20

    Persisting runtime properties

    I would appreciate some advice and/or pointers to sample code for persisting runtime properties of ActiveX components designed with VB.

    Thanks
    Sid

    Sid Price's Software Tools
    http://www.softtools.com/tools/

  2. #2
    Join Date
    Jun 2000
    Location
    Long Island NY
    Posts
    9

    Re: Persisting runtime properties


    option Explicit

    Dim m_myprop as string

    public property get MyProp() as string
    MyProp = m_myprop
    End property

    public property let MyProp(byval NewValue as string)
    m_myprop = NewValue
    PropertyChanged "MyProp"
    End property

    private Sub UserControl_ReadProperties(byref Propbag as PropertyBag)
    m_myprop = Propbag.ReadProperty("MyProp", "Default")
    End Sub

    private Sub UserControl_WriteProperties(byref Propbag as PropertyBag)
    Call Propbag.WriteProperty("MyProp", m_myprop, "Default")
    End Sub




    The Above is an example of how to create a property and persist it's value. You must be sure and call the PropertyChanged Method to alert the user control that a property has changed and that it needs to be written into the Propbag otherwise it will not persist between design-time and run-time.

    Hope this helps. Email me if you need more assistance.

    Alec Ruderman
    [email protected]



  3. #3
    Join Date
    Jun 1999
    Posts
    20

    Re: Persisting runtime properties

    Alec,

    Thanks for the response. However, I believe that the code you gave persists the property at design time only. If I am mistaken please excuse me.

    Sid

    Sid Price's Software Tools
    http://www.softtools.com/tools/

  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Persisting runtime properties

    There are several ways of persisting data at runtime, including :

    1. Using the registry (see the VB Help for GetSetting and SaveSetting for 'easy' registry access) - you can utilize the whole registry using code found on the CodeGuru site or any other big VB site.

    2. Saving data to files using 'Open xxx for output...' etc - check in the on-line help

    3. Saving / Restoring Data using XML (see the Microsoft site at http://msdn.microsoft.com/xml)

    4. Using the new 'persistable' classes in VB6 - these give you access to a property bag object at runtime and can be used in a similar way to usercontrols for reading / writing data

    Investigating the above will give you lots of ideas.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured