Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Erase Arrays

Hi:


I have 20 or so module-level arrays that I want to Erase after eac
calling. My current code follows:


Module A
-----------------------

Private Array1() as Integer, _
Array2() as Long, _
Array3() as Double, _
:
:
Array20() as Integer


Public Sub Sub1()
....Code
End Sub

Public Sub EraseArray()
Erase Array1
Erase Array2
:
:
Erase Array20
End Sub

-------------------------------

Module B
------------------------

Sub Sub2()
Dim i as Integer

For i = 1 to 3
Sub1
EraseArray
Next i

End Sub

-------------------------------------


I use EraseArray to make sure that the new run doesn't retain any ol
values. My question is there a way to reset my module-level arra
without actually typing all 20 or so arrays like what I did in my Su
EraseArray()



Regards,
Adrian

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Erase Arrays

I don't think there is any way to use a loop to erase your
arrays. You'll have to explicitly erase each one.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"adriant42 " wrote in
message ...
Hi:


I have 20 or so module-level arrays that I want to Erase after

each
calling. My current code follows:


Module A
-----------------------

Private Array1() as Integer, _
Array2() as Long, _
Array3() as Double, _
:
:
Array20() as Integer


Public Sub Sub1()
...Code
End Sub

Public Sub EraseArray()
Erase Array1
Erase Array2
:
:
Erase Array20
End Sub

-------------------------------

Module B
------------------------

Sub Sub2()
Dim i as Integer

For i = 1 to 3
Sub1
EraseArray
Next i

End Sub

-------------------------------------


I use EraseArray to make sure that the new run doesn't retain

any old
values. My question is there a way to reset my module-level

array
without actually typing all 20 or so arrays like what I did in

my Sub
EraseArray()



Regards,
Adrian T


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Erase Arrays

I don't know if you consider this any better, but you could create a
collection of your arrays and loop thru the collection.

Option Explicit
Private mcolArrays As Collection

Sub Main()
Set mcolArrays = New Collection
Dim Array1(1) As Integer
Dim Array2(1) As Integer
Dim Array3(1) As Integer
Dim Array4(1) As Integer
Array1(0) = 1
Array1(1) = 2
mcolArrays.Add Array1
mcolArrays.Add Array2
mcolArrays.Add Array3
mcolArrays.Add Array4
EraseArrays
End Sub

Public Sub EraseArrays()
Dim v As Variant
For Each v In mcolArrays
Erase v
Next v
End Sub


"adriant42 " wrote in message
...
Hi:


I have 20 or so module-level arrays that I want to Erase after each
calling. My current code follows:


Module A
-----------------------

Private Array1() as Integer, _
Array2() as Long, _
Array3() as Double, _
:
:
Array20() as Integer


Public Sub Sub1()
...Code
End Sub

Public Sub EraseArray()
Erase Array1
Erase Array2
:
:
Erase Array20
End Sub

-------------------------------

Module B
------------------------

Sub Sub2()
Dim i as Integer

For i = 1 to 3
Sub1
EraseArray
Next i

End Sub

-------------------------------------


I use EraseArray to make sure that the new run doesn't retain any old
values. My question is there a way to reset my module-level array
without actually typing all 20 or so arrays like what I did in my Sub
EraseArray()



Regards,
Adrian T


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
want to erase the 0 Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 4 September 16th 08 03:24 PM
erase page #1 momma Excel Discussion (Misc queries) 1 August 29th 07 09:34 PM
How to erase a column VBA Jepane Excel Discussion (Misc queries) 2 July 16th 07 02:26 PM
Erase Key in Legend Carlo Charts and Charting in Excel 5 August 30th 06 05:55 PM
Erase Duplicates John Excel Worksheet Functions 1 December 7th 05 05:16 PM


All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"