tinkythomas
Active Member
- Joined
- Dec 13, 2006
- Messages
- 432
Hi,
I'm trying to create some dynamic array class properties that are multi-dimensional. However I have been scratching my head for hours trying to get it to work.
The class module...
I'm getting Error 9 (Subscript out of range) when trying to assign values to the properties CellOriginalAddress and CellOriginalValue from a standard code module. I have declared the variable m_varCellOriginalValue as dynamic and not static.
Where am I going wrong?
Any help would be appreciated.
Regards,
I'm trying to create some dynamic array class properties that are multi-dimensional. However I have been scratching my head for hours trying to get it to work.
The class module...
Code:
Option Explicit
Private m_varCellOldValue As Variant
Private m_varCellNewValue As Variant
Private m_varCellOriginalValue() As Variant
Private m_intArrayIndex As Integer
Public Property Get ArrayIndex() As Integer
ArrayIndex = m_intArrayIndex
End Property
Public Property Let ArrayIndex(ByVal intArrayIndex As Integer)
m_intArrayIndex = intArrayIndex
End Property
Public Property Get CellNewValue() As Variant
CellNewValue = m_varCellNewValue
End Property
Public Property Let CellNewValue(ByVal varCellNewValue As Variant)
m_varCellNewValue = varCellNewValue
End Property
Public Property Get CellOldValue() As Variant
CellOldValue = m_varCellOldValue
End Property
Public Property Let CellOldValue(ByVal varCellOldValue As Variant)
m_varCellOldValue = varCellOldValue
End Property
Public Property Get CellOriginalAddress(intIndex As Integer) As Variant
CellOriginalAddress = m_varCellOriginalValue(intIndex, 0)
End Property
Public Property Let CellOriginalAddress(intIndex As Integer, varCellOriginalAddress As Variant)
m_varCellOriginalValue(intIndex, 0) = varCellOriginalAddress
End Property
Public Property Get CellOriginalValue(intIndex As Integer) As Variant
CellOriginalValue = m_varCellOriginalValue(intIndex, 1)
End Property
Public Property Let CellOriginalValue(intIndex As Integer, varCellOriginalValue As Variant)
m_varCellOriginalValue(intIndex, 1) = varCellOriginalValue
End Property
Public Function GetOriginalValue(strCellAddress As String) As Variant
' Variables
Dim i As Integer
Dim varOriginalValue As Variant
' Loop through array to find cell ref and corresponding value
10 For i = LBound(Me.CellOriginalValue, 1) To UBound(Me.CellOriginalValue, 1)
20 If Me.CellOriginalValue(i, 0) = strCellAddress Then
40 varOriginalValue = Me.CellOriginalValue(i, 1)
50 End If
60 Next i
70 GetOriginalValue = varOriginalValue
End Function
Where am I going wrong?
Any help would be appreciated.
Regards,