472,330 Members | 1,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

How to Pass collection between modules?

This is a basic program flow question.

I'm trying to refractor an AC2000 app and split sections of code into
separate modules. But there are a number of collections I create in one big
module - containing file paths, Excel worksheet names, etc - I'm not sure
how to pass these around, or if I'd be better off saving things to a table
and using a recordset. My guess is a recordset would be slower.

For example, should I do something like this:

[form module]
If basA.Function1 Then
If basB.Function.2 Then
If basC.Function3
Else
'code
End if
Else
'code
End if

(but then how to pass collections between modules?)

or just daily chain the modules:

[basA]
'code
Call basB (colX)

[basB]
'code
Call basC (colY)

etc..

Nov 13 '05 #1
4 11691
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

A Module is not a routine (Sub/Function). We do not pass parameters
between modules, but between routines in the modules. You can pass a
collection variable as you pass any other variable: as a parameter.
E.g.:

' inside a routine
Dim col As New Collection
...
col.Add "Fred"
col.Add "Harry"
MySub col ' <- the call to the other routine w/ the collection
---
' in another module
Public Sub MySub(MyCol As Collection)
' use the collection parameter
Dim nm As Variant
For Each nm In MyCol
Debug.Print nm
Next nm
End Function

Results (in debug window):
Fred
Harry
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQm1tEoechKqOuFEgEQKE5ACg1geSg/++CdXBKZ66HZ+AIRsEYkcAoI/g
jfJeqdCbu3XFQIk57pN8lqva
=8TgW
-----END PGP SIGNATURE-----

deko wrote:
This is a basic program flow question.

I'm trying to refractor an AC2000 app and split sections of code into
separate modules. But there are a number of collections I create in one big
module - containing file paths, Excel worksheet names, etc - I'm not sure
how to pass these around, or if I'd be better off saving things to a table
and using a recordset. My guess is a recordset would be slower.

For example, should I do something like this:

[form module]
If basA.Function1 Then
If basB.Function.2 Then
If basC.Function3
Else
'code
End if
Else
'code
End if

(but then how to pass collections between modules?)

or just daily chain the modules:

[basA]
'code
Call basB (colX)

[basB]
'code
Call basC (colY)

etc..

Nov 13 '05 #2
> A Module is not a routine (Sub/Function). We do not pass parameters
between modules, but between routines in the modules. You can pass a
collection variable as you pass any other variable: as a parameter.


Yes, that makes sense.

Perhaps using a public collection would work...

Option Compare Database
Option Explicit
Public MyCol as Collection

Public Function Put_Stuff_In_Collection
' code here
End Function

Now I can access the collection from the other modules.

As I mentioned, this app has grown considerably and I need to separate out
the code into different modules to keep it manageable. Otherwise I have a
module with about 1000 lines of code.

I'm also looking for alternatives to storing everything in a
table/recordset. VBA arrays just don't cut it, and collections are tricky
because they get re-indexed if I try to pop something out in the middle of a
loop.
Nov 13 '05 #3
rkc
deko wrote:
A Module is not a routine (Sub/Function). We do not pass parameters
between modules, but between routines in the modules. You can pass a
collection variable as you pass any other variable: as a parameter.

Yes, that makes sense.

Perhaps using a public collection would work...

Option Compare Database
Option Explicit
Public MyCol as Collection

Public Function Put_Stuff_In_Collection
' code here
End Function

Now I can access the collection from the other modules.

As I mentioned, this app has grown considerably and I need to separate out
the code into different modules to keep it manageable. Otherwise I have a
module with about 1000 lines of code.

I'm also looking for alternatives to storing everything in a
table/recordset. VBA arrays just don't cut it, and collections are tricky
because they get re-indexed if I try to pop something out in the middle of a
loop.


Where is the information coming from in the first place if not from
a recordset retrieved from some type of storage?

A VBA.Collection isn't much more that an array wrapped in a class with
a few methods to manipulate it. The collection itself becomes more
useful when wrapped in a class with methods to manipulate it. It's
a basic object that is most useful when you use it to build something
else. Having a collection floating around with nothing managing it is
really kind of sloppy.



Nov 13 '05 #4
> A VBA.Collection isn't much more that an array wrapped in a class with
a few methods to manipulate it. The collection itself becomes more
useful when wrapped in a class with methods to manipulate it. It's
a basic object that is most useful when you use it to build something
else. Having a collection floating around with nothing managing it is
really kind of sloppy.


Yeah, I guess I could just throw everything into a table. When in Rome...
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a...
3
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .......
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure ...
1
by: Andrzej Kaczmarczyk | last post by:
Hi, I am doing some complex configuration handling, and I have similiar setup: <DataSchema version="1.0"> <modules name="Assets"> <tables>...
54
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. ...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with...
109
by: jacob navia | last post by:
In an interviw with Dr Dobbs, Paul Jansen explains which languages are gaining in popularity and which not: <quote> DDJ: Which languages seem to...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor,...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.