Recycling Variables (Easy, I hope...)

Results 1 to 2 of 2

Thread: Recycling Variables (Easy, I hope...)

  1. #1
    Jason Miller Guest

    Default Recycling Variables (Easy, I hope...)

    This should be fairly easy (I hope), I&#039ve just not seen it before... I need to detonate an array so I can reuse it.<BR><BR>Situation: I found out about .getrows yesterday and I&#039ve got an app that needs it. The catch is that there is a single objRS which gets set (and then re-set) 4 times.<BR><BR>Now, I don&#039t want to be stuck with 4 2D arrays of recordsets I don&#039t really need -- is there any way I can just detonate the old array into a blank Variant? (the arrays are being passed back from a database handler, so I&#039m not sure reDim is a solution here)

  2. #2
    thad Guest

    Default RE: Recycling Variables (Easy, I hope...)

    Here&#039s what MS has to say about it. Looks like the big question is whether or not your arrays are fixed-size or dynamic.<BR>The Erase Statement<BR>Description<BR>Reinitializes the elements of fixed-size arrays and deallocates dynamic-array storage space.<BR>Syntax<BR>Erase array<BR>The array argument is the name of the array variable to be erased.<BR><BR>Remarks<BR>It is important to know whether an array is fixed-size (ordinary) or dynamic because Erase behaves differently depending on the type of array. Erase recovers no memory for fixed-size arrays. Erase sets the elements of a fixed array as follows:<BR>Type of array Effect of Erase on fixed-array elements <BR>Fixed numeric array Sets each element to zero. <BR>Fixed string array Sets each element to zero-length (""). <BR>Array of objects Sets each element to the special value Nothing. <BR><BR><BR>Erase frees the memory used by dynamic arrays. Before your program can refer to the dynamic array again, it must redeclare the array variable&#039s dimensions using a ReDim statement.<BR><BR>The following example illustrates the use of the Erase statement: <BR><BR>Dim NumArray(9) <BR>Dim DynamicArray()<BR>ReDim DynamicArray(9) &#039 Allocate storage space.<BR>Erase NumArray &#039 Each element is reinitialized.<BR>Erase DynamicArray &#039 Free memory used by array.<BR><BR>Good luck :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts