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.. 4 11990
-----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..
> 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.
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.
> 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... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
|
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>
|
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)
|
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>
|
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
| |
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....
|
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
|
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...
|
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
|
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...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |