vbCity/DevCity.NET Forums :: FAQ :: Visual Basic :: VB Controls & ActiveX :: General: "Creating persistable classes in VB6.0 can be tedious at best. But not anymore! Using the same object discovery techniques as VB's intellisense, this code makes persistable classes easy!
Code:
Private Sub Class_ReadProperties(PropBag As PropertyBag)
Dim ObjObject As New ObjectLister.ClsObject
Dim PropList As Collection
Dim I As Long
Set PropList = ObjObject.GetProperties(ObjObject.TypeInfoFromObject(Me))
With PropBag
For I = 1 To PropList.Count
Call ObjObject.Invoke(Me, PropList.Item(I).Name, PropList.Item(I).INVOKEKIND, .ReadProperty(PropList.Item(I).Name))
Next I
End With
Set PropList = Nothing
Set ObjObject = Nothing
End Sub
Private Sub Class_WriteProperties(PropBag As PropertyBag)
Dim ObjObject As New ObjectLister.ClsObject
Dim PropList As Collection
Dim I As Long
Set PropList = ObjObject.GetProperties(ObjObject.TypeInfoFromObject(Me))
With PropBag
For I = 1 To PropList.Count
Call .WriteProperty(PropList.Item(I).Name, ObjObject.Invoke(Me, PropList.Item(I).Name, VbGet))
Next I
End With
Set PropList = Nothing
Set ObjObject = Nothing
End Sub
The source code for the ObjectLister library is attached
The ObjectLister code was developed using a typelibrary and sample code from this site: Edanmo's VB Page"
0 Comments:
Post a Comment
<< Home