473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to pass an dynamic array between modules?

I have a dilemma where I am creating a dynamic two dimensional array
and filling it with information from a .csv file. Unfortunately,
later when I try to call that information back from the array I get an
error or I don't get anything back at all. I'm not sure how to make a
dynamic array public (so to speak) so that I can call the information
back between modules or forms. Can anyone help? Thanks.

Mar 29 '07 #1
3 5234
There are a couple of ways to deal with this. Way one is to make your
dynamic array global. That way it is not likely to go out of scope.
When the array goes out of scope, you lose all your data - the garbage
collector underneath the hood of Access will destroy all resources
connected to that array and release resources from the heap - deallocate
memory.

An easier way to deal with this would be to write the data from the CSV
file to a table. Then use the data from the table.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Mar 29 '07 #2
Pass the array by reference within the function.

Public Function fGetContentsStream(ByRef arrayOLE() As Byte, _
FileExtension As String, _
Optional FileNamePackage As String = "") As Boolean

Now in the function itself, you can redim the array as desired.

' Size our main array
ReDim arrayOLE(0 To UBound(arrayB))

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Troy" <Tr**********@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
>I have a dilemma where I am creating a dynamic two dimensional array
and filling it with information from a .csv file. Unfortunately,
later when I try to call that information back from the array I get an
error or I don't get anything back at all. I'm not sure how to make a
dynamic array public (so to speak) so that I can call the information
back between modules or forms. Can anyone help? Thanks.

Mar 29 '07 #3
Hi Troy,

You can also pass the array to a sub the same way as a function, as
long as you use the byref keyword.

If you make the array global it will be available to everything, and
if you simply dim it inside a procedure it will be destroyed at the
end of the procedure.

The key here in using it is to make sure you use the ByRef keyword
when passing it around if you want to 'send' it to a sub or function.

Cheers

The Frog

Mar 30 '07 #4

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

Similar topics

6
by: Vasileios Zografos | last post by:
Hello, I have a function that generates some values (e.g. vertices in 2d space) the number of which I dont know. So, it could generate 20 vertices, 100 vertices, or even 1 vertex. void...
4
by: deko | last post by:
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 -...
8
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was...
2
by: xinsir | last post by:
dynamic array as a byref parameter by used in function and have a Marshal error ,what is the matter?thanks source like as this . ------------------------------------------------------ Declare...
13
by: lovecreatesbeauty | last post by:
/* How do free() know how many elements should be freed in a dynamic array? When free a single variable, the amount of byte of memory can be retrieved from the type of variable itself. ...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
1
by: Gurur | last post by:
Hi all, I have a doubt. If I have 2 structures and one is parent of other , ie the child structure is present in the parent one . And if the child structure is declared as dynamic array in the...
11
by: C C++ C++ | last post by:
Hi all, got this interview question please respond. How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Rgrds MA
13
by: kwikius | last post by:
Does anyone know what a C99 dynamic array is, and if it will be useable in C++? regards Andy Little
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
jinu1996
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...

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.