I'd like to be able to pass an array-within-an-array from a class, but I'm having difficulty. Here's the Class1 code:
Now, on my Form1, I have a command button. It's Click event runs the following code:
The error I am getting is a "ByRef argument type mismatch" error which points to the Private Sub Command1_Click() line. This error just started to come up unexpectedly. Before that, I was getting a generic "Type mismatch" error on the For loop.
Can anyone help me with this?
Code:
Private m_Records() As Variant
Property Get Records(Optional Index As Integer = 0) As Variant
Records = m_Records(Index)
End Property
Property Let Records(Optional Index As Integer = 0, newvalue As Variant)
If Index < LBound(m_Records) Or Index > UBound(m_Records) Then Err.Raise 9
m_Records(Index) = newvalue
End Property
Public Sub Run()
countr = 0
Do Until criteria
ReDim Preserve Records(countr) As Variant
Dim tempArray(4)
tempArray(0) = "Val1"
tempArray(1) = "Val2"
tempArray(2) = "Val3"
tempArray(3) = "Val4"
tempArray(4) = "Val5"
Records(countr) = tempArray
countr = countr + 1
Loop
End Sub
Now, on my Form1, I have a command button. It's Click event runs the following code:
Code:
Private Sub Command1_Click()
Dim ret As Class1
Set ret = New Class1
ret.Run
For i = 0 To UBound(ret.Records)
Print ret.Records(i)(0) ' if I wanted to just print the first value of the interior array
Next
Set ret = Nothing
End Sub
The error I am getting is a "ByRef argument type mismatch" error which points to the Private Sub Command1_Click() line. This error just started to come up unexpectedly. Before that, I was getting a generic "Type mismatch" error on the For loop.
Can anyone help me with this?