Home |
Search |
Today's Posts |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
update collection of arrays | Excel Programming | |||
VSTO: Sheets collection a 1-based array(?!?!?) | Excel Programming | |||
Writing to An Array or Collection | Excel Programming | |||
How to Access Array of Arrays? | Excel Programming | |||
Array of Arrays in VBA | Excel Programming |