- Код: Выделить всё
'local variable(s) to hold property value(s)
Private mvarParameters As Variant 'local copy
Public Function GetParametersCount() As Integer
If IsArray(mvarParameters) Then
GetParametersCount = UBound(mvarParameters) - LBound(mvarParameters)
Else
GetParametersCount = 0
End If
End Function
Public Function GetParameter(Index As Integer) As Object
If Index > GetParametersCount Then
GetParameter = Null
Else
GetParameter = mvarParameters(Index)
End If
End Function
Public Sub AddParameter(ByVal Name As String, ByRef Value As Variant)
If IsArray(mvarParameters) Then
ReDim Preserve mvarParameters(GetParametersCount + 1)
Else
ReDim mvarParameters(1)
End If
Dim tObject As Object
tObject.Name = Name
tObject.Value = Value
mvarParameters(UBound(mvarParameters)) = tObject
End Sub
Public Property Let Parameters(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Parameters = 5
mvarParameters = vData
End Property
Public Property Set Parameters(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.Parameters = Form1
Set mvarParameters = vData
End Property
Public Property Get Parameters() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Parameters
If IsObject(mvarParameters) Then
Set Parameters = mvarParameters
Else
Parameters = mvarParameters
End If
End Property
Пытаюсь создать объект этого класса и вызвать метод AddParameter
- Код: Выделить всё
'...
Dim ProgramParameters As mProjectParameters
Set ProgramParameters = New mProjectParameters
'...
'Здесь pName задается строкой, pValueArr - массивом
'...
ProgramParameters.AddParameter(byval pName, pValueArr)
Последняя приведенная строка выдает ошибку компиляции "Expected: ="
Почему? Что не так делаю?