How to reinitialize an array? 
Author Message
 How to reinitialize an array?

I have an array declared in a VB module like so:

Global gnTempData(0 To 99999, 1 To 8) As Integer

I would like to have a clear option where the user could wipe out all
the data that they've recorded.  I tried the following which (not too
surprisingly) crashed:

Private Sub mnuDisplayClear_Click()

   ReDim gnTempData(0 To 99999, 1 To 8)

End Sub

What would be the best way to clear out the contents of a large array?
--
To respond via e-mail, please remove what's between Eric and Goforth in
my address in order to get my real e-mail address.



Sat, 06 Oct 2001 03:00:00 GMT  
 How to reinitialize an array?
Global gnTempData() As Integer

then somewhere before first use
ReDim gnTempData(0 To 99999, 1 To 8)

Quote:

> I have an array declared in a VB module like so:

> Global gnTempData(0 To 99999, 1 To 8) As Integer

> I would like to have a clear option where the user could wipe out all
> the data that they've recorded.  I tried the following which (not too
> surprisingly) crashed:

> Private Sub mnuDisplayClear_Click()

>    ReDim gnTempData(0 To 99999, 1 To 8)

> End Sub

> What would be the best way to clear out the contents of a large array?
> --
> To respond via e-mail, please remove what's between Eric and Goforth in
> my address in order to get my real e-mail address.

--



Sat, 06 Oct 2001 03:00:00 GMT  
 How to reinitialize an array?
How about the Erase command.

From the help file (VB6):
Erase Statement: Reinitializes the elements of fixed-sizearrays and releases
dynamic-array storage space.
Syntax: Erase arraylist: The required arraylistargument is one or more
comma-delimited arrayvariables to be erased.

Maybe something like:

Private Sub mnuDisplayClear_Click()
    Erase gnTempData
    ReDim gnTempData(0 To 99999, 1 To 8)
End Sub

Quote:

> Global gnTempData() As Integer

> then somewhere before first use
> ReDim gnTempData(0 To 99999, 1 To 8)


> > I have an array declared in a VB module like so:

> > Global gnTempData(0 To 99999, 1 To 8) As Integer

> > I would like to have a clear option where the user could wipe out all
> > the data that they've recorded.  I tried the following which (not too
> > surprisingly) crashed:

> > Private Sub mnuDisplayClear_Click()

> >    ReDim gnTempData(0 To 99999, 1 To 8)

> > End Sub

> > What would be the best way to clear out the contents of a large array?
> > --
> > To respond via e-mail, please remove what's between Eric and Goforth in
> > my address in order to get my real e-mail address.

> --




Sat, 06 Oct 2001 03:00:00 GMT  
 How to reinitialize an array?
Eric,

You can use VB's Erase command to re-initialize a fixed-size array.

Or you can use a dynamic array and ReDimension it to re-initialize it.

Hope this helps,

Kerry moorman



Quote:
> I have an array declared in a VB module like so:

> Global gnTempData(0 To 99999, 1 To 8) As Integer

> I would like to have a clear option where the user could wipe out all
> the data that they've recorded.  I tried the following which (not too
> surprisingly) crashed:

> Private Sub mnuDisplayClear_Click()

>    ReDim gnTempData(0 To 99999, 1 To 8)

> End Sub

> What would be the best way to clear out the contents of a large array?
> --
> To respond via e-mail, please remove what's between Eric and Goforth in
> my address in order to get my real e-mail address.



Sat, 06 Oct 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Closing and reinitializing user form

2. reinitialize a public object

3. Reinitialize the date

4. Form-Level variables don't reinitialize

5. Error in Reinitializing Microsoft Internet Transfer control

6. ReInitialize after running code

7. Arrays in Collections, Arrays in Arrays

8. Array of Arrays and 2D array

9. String to Array and Array to String

10. Filling a 3-D array from another array??

11. Change Array to Multidimensional Array

12. Arrays and pointers to arrays

 

 
Powered by phpBB® Forum Software