Davidprince
Programmer
Ladies and Gentlemen
This is a follow on from my last question, but unlike the last post this gets to the heart of the matter. My apologies for not thinking of this before posting the earlier query. I have found lots of valuable information on arrays and one example that, whilst obvious in how passing an array is done, didn't contain much of an explanation of what was occurring. Anyway, I would be grateful if someone can comment on the step with the 'CONFUSED note:
Sub AAATest()
Dim StaticArr(1 To 3) As Long
Dim N As Long
StaticArr(1) = 1
StaticArr(2) = 2
StaticArr(3) = 3
PopulatePassedArray Arr:=StaticArr 'CONFUSED
For N = LBound(StaticArr) To UBound(StaticArr)
Cells(N, 1) = StaticArr(N)
Next N
End Sub
Sub PopulatePassedArray(ByRef Arr() As Long)
''''''''''''''''''''''''''''''''''''
' PopulatePassedArray
' This puts some values in Arr.
''''''''''''''''''''''''''''''''''''
Dim N As Long
For N = LBound(Arr) To UBound(Arr)
Arr(N) = N * 10
Next N
End Sub
I realise what PopulatePassedArray is about but am confused by the reference to Arr:=StaticArray. What am I missing in the syntax?
Cheers
David
This is a follow on from my last question, but unlike the last post this gets to the heart of the matter. My apologies for not thinking of this before posting the earlier query. I have found lots of valuable information on arrays and one example that, whilst obvious in how passing an array is done, didn't contain much of an explanation of what was occurring. Anyway, I would be grateful if someone can comment on the step with the 'CONFUSED note:
Sub AAATest()
Dim StaticArr(1 To 3) As Long
Dim N As Long
StaticArr(1) = 1
StaticArr(2) = 2
StaticArr(3) = 3
PopulatePassedArray Arr:=StaticArr 'CONFUSED
For N = LBound(StaticArr) To UBound(StaticArr)
Cells(N, 1) = StaticArr(N)
Next N
End Sub
Sub PopulatePassedArray(ByRef Arr() As Long)
''''''''''''''''''''''''''''''''''''
' PopulatePassedArray
' This puts some values in Arr.
''''''''''''''''''''''''''''''''''''
Dim N As Long
For N = LBound(Arr) To UBound(Arr)
Arr(N) = N * 10
Next N
End Sub
I realise what PopulatePassedArray is about but am confused by the reference to Arr:=StaticArray. What am I missing in the syntax?
Cheers
David