Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function return by reference
I have a class that contains a variant array. I have a public property
that allows access to the variant array. However, the public property returns the variant array by value. How can I force a function to return the variant array by reference? private m_vntData as variant |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function return by reference
Sub test()
Dim myARy Dim i As Long myARy = [{1,2,3}] For i = LBound(myARy, 1) To UBound(myARy, 1) Debug.Print myARy(i) Next i ByRefCall myARy For i = LBound(myARy, 1) To UBound(myARy, 1) Debug.Print myARy(i) Next i End Sub Function ByRefCall(ByRef ary) Dim i As Long For i = LBound(ary, 1) To UBound(ary, 1) ary(i) = ary(i) * 2 Next i End Function -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "R Avery" wrote in message ... I have a class that contains a variant array. I have a public property that allows access to the variant array. However, the public property returns the variant array by value. How can I force a function to return the variant array by reference? private m_vntData as variant |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function return by reference
Sorry if i was not more clear. I wish the function to actually RETURN
the reference, not just set an argument that is passed in as reference. I want to be able to do things like myClass.myData(1,2) = 3.14..... if possible, that is. I don't want to have to declare a separate array, set that array equal to the array in the class, and then set individual items in the array. Of course, if this is not possible, then I'll have to turn to solutions like the one you presented. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function return by reference
in Bob's example, ary and myary are the same memory space - there is no
duplication. If the array was duplicated, then you would get 1 2 3 1 2 3 rather than 1 2 3 4 5 6 -- Regards, Tom Ogilvy "R Avery" wrote in message ... Sorry if i was not more clear. I wish the function to actually RETURN the reference, not just set an argument that is passed in as reference. I want to be able to do things like myClass.myData(1,2) = 3.14..... if possible, that is. I don't want to have to declare a separate array, set that array equal to the array in the class, and then set individual items in the array. Of course, if this is not possible, then I'll have to turn to solutions like the one you presented. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
function to find value and return cell reference | Excel Discussion (Misc queries) | |||
how do I create a cell reference from ADDRESS function return? | Excel Worksheet Functions | |||
Return value in cell above the reference | Excel Discussion (Misc queries) | |||
check if reference exists, then return its value or return 0 | Excel Worksheet Functions | |||
return the column reference number of a function result | Excel Discussion (Misc queries) |