473,703 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11980
-----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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQm1tEoechKq OuFEgEQKE5ACg1g eSg/++CdXBKZ66HZ+AI RsEYkcAoI/g
jfJeqdCbu3XFQIk 57pN8lqva
=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_Co llection
' 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_Co llection
' 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
3510
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 large list or dictionary? It could achieved by pointer in C++, is there such way in Python? Thansk in advance. J.R.
3
3051
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= .... >>> X.g <unbound method X.f>
1
7674
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 (I've also copied and pasted the whole contents into the bottom of this email)
1
3600
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> <tables description="" singular="" plural="" name="City" /> </tables> </modules>
54
3245
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. Nearly 3 years ago, something was mentioned in this NG to the effect that "...when you access a module programatically, there is a lines collection..." Have any of you experimented with your own procedures to aid in numbering lines? Would the lines collection be of some
19
4911
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 my understanding of Class Modules with the exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom controls which utilize custom classes to wrap built-in controls, and add additional functionality....
109
3921
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 be losing ground? PJ: C and C++ are definitely losing ground. There is a simple explanation for this. Languages without automated garbage collection are getting out of fashion. The chance of running into all kinds of memory problems is gradually outweighing the performance penalty you have to
12
11095
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
158
7812
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 way the language is designed. Or it is discouraged due to some specific reason. If someone can give inputs on the same, it will be of great help. Regards, Pushpa
0
8755
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8667
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9249
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7860
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2445
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.