LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Collection vs. Array of Arrays, nszim

Hi KIC,
thanks so much for your reply. Since I'm very much in learning mode, I
asked the general question. I can use a collection for some data that is
'read only' in the appl. I'm developing. The original mistake that I made
was that I got tired of typing is so many var names when I call a procedu
call mysub (var1, var2, etc......)
so I declared a lot of variables and arrays and then found out this was not
a great idea.
I use a LOT of called procs in my macros and what was looking for the
best way to minimize the re-writing I have to do to get rid of all the
variables in the declarations section that should not be there.
I know that I can use this approach:
call mysub(inputstuff,intArray,stringAry)
and am analyzing what will be best for the work I have to do.
Thanks again for your response,
Neal


"keepITcool" wrote:


if you need to store and manipulate data, i'd stick with arrays.
as a first thought i would NOT go with your array of arrays approach,
but use a simple 2 dimensional variant array.
(variants are fractionally slower than strongly typed arrays,
but can hold all data types)

You'd use a collection if you need to repeatedly READ items from a
datasource, and need indexed access. Changing data in a collection is
much slower and trickier than changing data in an array.

in your example using a collection to hold 2 arrays is counter
productive, why not simply use

call mysub(inputstuff,intArray,stringAry) ???

(i'd use more structured naming but that's a different matter :)




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Neal Zimm wrote :

I am mostly self taught in vba, but with other programming experience.
In my app, I have a need to store character and integer variables in
arrays. To date, since the numbers are small I dim an example array
as: dim Array(10,6) as string
When I 'read' from the array I convert the 'string' numbers into
integer vars, and vice-versa when I put values into the array. It's
getting to be a pain to do this.
In reading MSoft docum in vba, I guess I could make an integer
array and a string array and 'combine' them into a holding array for
transport in called subs. e.g.
dim IntArray(x,y) as integer
dim StringAry(a,b) as string
dim master(2)
master(1)=intarray
master(2)=stringary
...
then, call mySub(inputstuff,master)
where mysub operates on the elements of master individually.

I've read a little bit about collections and that function appears to
do about the same thing as the above.
1. WHAT ARE THE BIG PRO'S AND CON'S OF COLLECTIONS VS. AN ARRAY
OF ARRAYS?

2. I've been looking for, in the "collections arena" of Excel
docum. how to
"directly" address the elements of an array that is part of a
collection. I have not found any and indeed do not know it it's even
possible. In other words,
if the collection is composed of these two arrays: and the collection
is named:
COLL,
IntArray(x,y) as integer (item 1 in COLL)
StringAry(a,b) as integer (item 2 in COLL)
IS THERE A WAY TO ADDRESS IntArray(3,4) by using the name
of the Collection? Kinda like: NewVar = COLL(1, ????) to try
and grab the value in IntArray(3,4) without using the IntArray
'name'?

Thanks.
Neal Z


 
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
update collection of arrays RB Smissaert Excel Programming 7 December 26th 05 09:28 AM
VSTO: Sheets collection a 1-based array(?!?!?) Bob Sullentrup Excel Programming 0 November 10th 05 04:10 PM
Writing to An Array or Collection vqthomf Excel Programming 4 August 23rd 05 02:07 PM
How to Access Array of Arrays? billbell52 Excel Programming 1 February 24th 05 06:05 PM
Array of Arrays in VBA Peter[_49_] Excel Programming 0 November 9th 04 09:50 PM


All times are GMT +1. The time now is 10:08 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"