Clearing an Array



Hi everyone,

I want to clear the contents of an array. I know that redimensioning an
array also clears it. So, I decided to clear the array by
redimensioning to zero and then re-redimensioning it back to what it
was. So, I wrote the following:

Sub test()
Static vDlt(1 To 52) As Boolean

ReDim vDlt(0) As Boolean
ReDim vDlt(1 To 52) As Boolean
End Sub

When I run this I get the error message "Compile error: array already
dimensioned". Microsoft help has this to say on the issue:

"You can use the ReDim statement repeatedly to change the number of
elements and dimensions in an array."

Does anybody know what is going on here? Also, is there a more elegant
way of clearing the array?

Thank you now for any responses but I will always get back to you with
feedback.

Regards,

Terry.

.



Relevant Pages

  • RE: Class Property as an Array
    ... ReDim blnArrayAs Boolean ... This example creates a dynamic array, which you seem you be able ... Tim ...
    (microsoft.public.vb.general.discussion)
  • Re: Clearing an Array
    ... You need to dimension the array as a dynamic array vDlt() then you can ... ReDim vDltAs Boolean ...
    (microsoft.public.excel)
  • Re: Clearing an Array
    ... I want to clear the contents of an array. ... redimensioning to zero and then re-redimensioning it back to what it ... Static vDltAs Boolean ... ReDim vDltAs Boolean ...
    (microsoft.public.excel)
  • Re: ReDim Object array as parameter of Variant array
    ... > the array and then reassigning it after redimensioning is what works. ... and also slower than the multiple Class array method I described (which I ... But I don't know the eventual required size of these object arrays ... >> Peter T ...
    (microsoft.public.excel.programming)
  • Re: Can I test dynamic array for empty?
    ... I'm building dynamic arrays with the elements I find. ... I would like an elegant way to determing if anything has been put into my dynamic array yet. ... Before the array has been ReDim-ed the first type, attempts to use LBound or UBound give subscript out of range errors. ... I've been working around this by Redimensioning the array as until the first use, then Redimensioning as for the first element, next, etc., but this is clunky and using 1-based subscripts isn't portable to VB.Net, which I may do in the future. ...
    (microsoft.public.excel.programming)