Creat/Resize an array without knowing the array type
Posted on 2005-03-06
I want to do the following,
I have a class with many member variables that are arrays of typed objects. I am constantly have to check if I should resize the array to add another object or create a new array. So I was thinkin about creating the following Utility class. But, I don't know how to create the array properly in the first if block.
Also, will the byref call work like i want it to if I call
AddObjectToArray(myObj, myBigObj.myArrayOfMyObjs) with myBigObj.myArrayOfMyObjs as Nothing?
Public Shared Sub AddObjectToArray(ByVal obj As Object, ByRef array As Object())
If (array Is Nothing) Then
'create array here
'resize the array and add this in
ReDim Preserve array(array.Length)
array(array.Length - 1) = obj