1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "LayoutPropertySet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Collection" ,"LayoutProperty"
Attribute VB_Ext_KEY = "Member0" ,"LayoutProperty"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'local variable to hold collection
Private mCol As Collection
'
' Avoids duplicates. If only an update is done than is returns 'Nothing'; otherwise
' returns the newly created LayoutProperty instance
'
Public Function Add(Scope As String, Value As String, PName As String) As LayoutProperty
Dim objNewMember As LayoutProperty
Set objNewMember = Item(PName, Scope)
If Not objNewMember Is Nothing Then
objNewMember.Value = Value
Set objNewMember = Nothing
Else
Set objNewMember = New LayoutProperty
'set the properties passed into the method
objNewMember.Scope = Scope
objNewMember.Value = Value
objNewMember.PName = PName
mCol.Add objNewMember, objNewMember.Id
End If
'return the object
Set Add = objNewMember
Set objNewMember = Nothing
End Function
Public Property Get ItemByPos(Pos As Integer) As LayoutProperty
Set ItemByPos = mCol.Item(Pos)
End Property
Public Property Get Item(thePName As String, theScope As String) As LayoutProperty
Attribute Item.VB_UserMemId = 0
Dim p As LayoutProperty
Dim i As Integer
i = Pos(thePName, theScope)
If i = 0 Then
Set Item = Nothing
Else
Set Item = mCol(i)
End If
End Property
'finds the position of a given property, returns 0 if not found
Public Function Pos(thePName As String, theScope As String) As Integer
Dim i As Integer
Dim p As LayoutProperty
For i = 1 To mCol.Count
Set p = mCol(i)
If p.PName = thePName And p.Scope = theScope Then
Pos = i
Exit Function
End If
Next i
Pos = 0
End Function
Public Property Get Count() As Long
'used when retrieving the number of elements in the
'collection. Syntax: Debug.Print x.Count
Count = mCol.Count
End Property
Public Function Remove(PName As String, Scope As String) As LayoutProperty
Set Remove = Item(PName, Scope)
If Not Remove Is Nothing Then
mCol.Remove Remove.Id
End If
End Function
Public Function RemoveByPos(Pos As Integer) As LayoutProperty
Set RemoveByPos = mCol.Item(Pos)
If Not RemoveByPos Is Nothing Then
mCol.Remove RemoveByPos.Id
End If
End Function
Public Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
'this property allows you to enumerate
'this collection with the For...Each syntax
Set NewEnum = mCol.[_NewEnum]
End Property
Private Sub Class_Initialize()
'creates the collection when this class is created
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
'destroys collection when this class is terminated
Set mCol = Nothing
End Sub
Public Function ToString() As String
Dim p As LayoutProperty
For Each p In mCol
ToString = ToString & " " & p.ToString
Next p
End Function
Public Sub Clear()
While mCol.Count <> 0
mCol.Remove 1
Wend
End Sub
|