Hey guys,
I've got a question about arrays and I think it's related to the data types.
I want to construct a generic function that I can use on multiple arrays.
Basically I've got a number of arrays which I need to fill. To do that I created a generic function that adds a value to an array.
Now I'm trying to put the Arrayname also in that function so that I only have to call the function with the name of the array and the value and the value is inserted in the array.
I'll give you the code to make myself clear:
The problem probably lies in the name of the array that I'm sending to the function. Here I put it in brackets like it is a string, but I know it's not. It's an array.
Anybody have any ideas on how to solve this?
Thanks.
Cainnech
I've got a question about arrays and I think it's related to the data types.
I want to construct a generic function that I can use on multiple arrays.
Basically I've got a number of arrays which I need to fill. To do that I created a generic function that adds a value to an array.
Now I'm trying to put the Arrayname also in that function so that I only have to call the function with the name of the array and the value and the value is inserted in the array.
I'll give you the code to make myself clear:
Code:
function AddToArray(arr, value)
if ubound(arr) = -1 then
ReDim arr(0)
arr(0) = value
else
ReDim Preserve arr(ubound(arr) + 1)
arr(ubound(arr)) = value
end if
end function
Dim output
output = Array()
AddToArray("output", "AnyGivenValue")
Anybody have any ideas on how to solve this?
Thanks.
Cainnech
Comment