469,111 Members | 1,974 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,111 developers. It's quick & easy.

Out of memory

Hello,

I was wondering if anyone can help. I wrote a program in VBA. It does some
calculations with matrices (arrays) . These arrays are dynamic and are sized
according to a user defined input. The program works great when woriking
with a small number but as the number increases (estimate about a 50 x 50
array) the program will give a runtime error 7 message "Out of memory". 50 x
50 array does not seem like a lot and when I looked into the help there was
a mention of a 64k segment boundary. I'm not sure what this is, can anyone
help explain this ?

I was thinking this may be a limitation with running VBA on excel and wanted
to compile a stand alone executable program that will take the data placed
in excel cell and do all the number crunching in the program. I was hoping
someone could help me with the syntax to set a constant in a VB program and
set it equal to a cell or range in an excel spreadsheet (one that is open,
if this matters) and then write data to an excel range after calculations
have been done.
Thanks

Jul 17 '05 #1
5 21926
Does your VB application use the VBA Forms 2.0 controls? These are not
supported under VB, and will generate that error. The fix is to not use
these controls.

Do you use the data combo control along with its boundtext property? This
will throw an error if the list is scrolled to view additional items. There
is no fix.

How long are the strings assigned to the array members (I'm presuming the
array is defined as string, and not as a numeric data type). If significant,
remember that when you redim preserve VB creates a new array then copies the
current array into it. This requires double the memory while these two
arrays are alive.

What is code where the error occurs, and on which specific line? Include
declares and sample data.

--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"Tmenke" <me*****@netscape.net> wrote in message
news:1M***************@fe40.usenetserver.com...
: Hello,
:
: I was wondering if anyone can help. I wrote a program in VBA. It does some
: calculations with matrices (arrays) . These arrays are dynamic and are
sized
: according to a user defined input. The program works great when woriking
: with a small number but as the number increases (estimate about a 50 x 50
: array) the program will give a runtime error 7 message "Out of memory". 50
x
: 50 array does not seem like a lot and when I looked into the help there
was
: a mention of a 64k segment boundary. I'm not sure what this is, can anyone
: help explain this ?
:
: I was thinking this may be a limitation with running VBA on excel and
wanted
: to compile a stand alone executable program that will take the data placed
: in excel cell and do all the number crunching in the program. I was hoping
: someone could help me with the syntax to set a constant in a VB program
and
: set it equal to a cell or range in an excel spreadsheet (one that is open,
: if this matters) and then write data to an excel range after calculations
: have been done.
:
:
: Thanks
:
:
:

Jul 17 '05 #2
I'm sorry if I wasn't clear. The first program I wrote was in VBA for excel.
I want to take the code
from the program and compile it with VB to see if will bust the memory like
my VBA app is doing as my dynamic arrays get larger. The content of the
array is all numbers but it is declared as variant (default). I have bad
programming habits , I am only a hobbiest and not a professional.

I would be interested to see if anyone has experienced this run time 7
error.

But mainly, I would like to know if any one knows what the code is to equate
a variable in a vb program to a range or cell in microsoft excea and vice
versa

Thanks for your interest!
"Randy Birch" <rg************@mvps.org> wrote in message
news:0_********************@rogers.com...
Does your VB application use the VBA Forms 2.0 controls? These are not
supported under VB, and will generate that error. The fix is to not use
these controls.

Do you use the data combo control along with its boundtext property? This
will throw an error if the list is scrolled to view additional items. There is no fix.

How long are the strings assigned to the array members (I'm presuming the
array is defined as string, and not as a numeric data type). If significant, remember that when you redim preserve VB creates a new array then copies the current array into it. This requires double the memory while these two
arrays are alive.

What is code where the error occurs, and on which specific line? Include
declares and sample data.

--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"Tmenke" <me*****@netscape.net> wrote in message
news:1M***************@fe40.usenetserver.com...
: Hello,
:
: I was wondering if anyone can help. I wrote a program in VBA. It does some : calculations with matrices (arrays) . These arrays are dynamic and are
sized
: according to a user defined input. The program works great when woriking
: with a small number but as the number increases (estimate about a 50 x 50 : array) the program will give a runtime error 7 message "Out of memory". 50 x
: 50 array does not seem like a lot and when I looked into the help there
was
: a mention of a 64k segment boundary. I'm not sure what this is, can anyone : help explain this ?
:
: I was thinking this may be a limitation with running VBA on excel and
wanted
: to compile a stand alone executable program that will take the data placed : in excel cell and do all the number crunching in the program. I was hoping : someone could help me with the syntax to set a constant in a VB program
and
: set it equal to a cell or range in an excel spreadsheet (one that is open, : if this matters) and then write data to an excel range after calculations : have been done.
:
:
: Thanks
:
:
:


Jul 17 '05 #3
I think you should sort out why you are getting an error with a tiny
array of 50 x 50 numbers. 2500 elements is peanuts. 500 x 500 should be
no problem. 5000 x 5000, or 25 million elements, might be a problem.
There must be something else you are doing that is causing the problem.

As far as using Excel from VB, set a reference in VB to the Excel Object
Library. You can then declare variables of type Excel.Application,
Excel.Workbook, Excel.Worksheet, Excel.Range, etc. and run excel
directly from your VB app.

"Tmenke" <me*****@netscape.net> wrote in message
news:QR***************@fe40.usenetserver.com...
| I'm sorry if I wasn't clear. The first program I wrote was in VBA for
excel.
| I want to take the code
| from the program and compile it with VB to see if will bust the memory
like
| my VBA app is doing as my dynamic arrays get larger. The content of
the
| array is all numbers but it is declared as variant (default). I have
bad
| programming habits , I am only a hobbiest and not a professional.
|
| I would be interested to see if anyone has experienced this run time 7
| error.
|
| But mainly, I would like to know if any one knows what the code is to
equate
| a variable in a vb program to a range or cell in microsoft excea and
vice
| versa
|
| Thanks for your interest!
|
|
| "Randy Birch" <rg************@mvps.org> wrote in message
| news:0_********************@rogers.com...
| > Does your VB application use the VBA Forms 2.0 controls? These are
not
| > supported under VB, and will generate that error. The fix is to not
use
| > these controls.
| >
| > Do you use the data combo control along with its boundtext property?
This
| > will throw an error if the list is scrolled to view additional
items.
| There
| > is no fix.
| >
| > How long are the strings assigned to the array members (I'm
presuming the
| > array is defined as string, and not as a numeric data type). If
| significant,
| > remember that when you redim preserve VB creates a new array then
copies
| the
| > current array into it. This requires double the memory while these
two
| > arrays are alive.
| >
| > What is code where the error occurs, and on which specific line?
Include
| > declares and sample data.
| >
| > --
| >
| >
| > Randy Birch
| > MS MVP Visual Basic
| > http://vbnet.mvps.org/
| >
| >
| > "Tmenke" <me*****@netscape.net> wrote in message
| > news:1M***************@fe40.usenetserver.com...
| > : Hello,
| > :
| > : I was wondering if anyone can help. I wrote a program in VBA. It
does
| some
| > : calculations with matrices (arrays) . These arrays are dynamic and
are
| > sized
| > : according to a user defined input. The program works great when
woriking
| > : with a small number but as the number increases (estimate about a
50 x
| 50
| > : array) the program will give a runtime error 7 message "Out of
memory".
| 50
| > x
| > : 50 array does not seem like a lot and when I looked into the help
there
| > was
| > : a mention of a 64k segment boundary. I'm not sure what this is,
can
| anyone
| > : help explain this ?
| > :
| > : I was thinking this may be a limitation with running VBA on excel
and
| > wanted
| > : to compile a stand alone executable program that will take the
data
| placed
| > : in excel cell and do all the number crunching in the program. I
was
| hoping
| > : someone could help me with the syntax to set a constant in a VB
program
| > and
| > : set it equal to a cell or range in an excel spreadsheet (one that
is
| open,
| > : if this matters) and then write data to an excel range after
| calculations
| > : have been done.
| > :
| > :
| > : Thanks
| > :
| > :
| > :
| >
|
|
|
Jul 17 '05 #4
Could you give me some ideas on chasing down and debugging a problem like
this
"Steve Gerrard" <my********@comcast.net> wrote in message
news:1r********************@comcast.com...
I think you should sort out why you are getting an error with a tiny
array of 50 x 50 numbers. 2500 elements is peanuts. 500 x 500 should be
no problem. 5000 x 5000, or 25 million elements, might be a problem.
There must be something else you are doing that is causing the problem.

As far as using Excel from VB, set a reference in VB to the Excel Object
Library. You can then declare variables of type Excel.Application,
Excel.Workbook, Excel.Worksheet, Excel.Range, etc. and run excel
directly from your VB app.

"Tmenke" <me*****@netscape.net> wrote in message
news:QR***************@fe40.usenetserver.com...
| I'm sorry if I wasn't clear. The first program I wrote was in VBA for
excel.
| I want to take the code
| from the program and compile it with VB to see if will bust the memory
like
| my VBA app is doing as my dynamic arrays get larger. The content of
the
| array is all numbers but it is declared as variant (default). I have
bad
| programming habits , I am only a hobbiest and not a professional.
|
| I would be interested to see if anyone has experienced this run time 7
| error.
|
| But mainly, I would like to know if any one knows what the code is to
equate
| a variable in a vb program to a range or cell in microsoft excea and
vice
| versa
|
| Thanks for your interest!
|
|
| "Randy Birch" <rg************@mvps.org> wrote in message
| news:0_********************@rogers.com...
| > Does your VB application use the VBA Forms 2.0 controls? These are
not
| > supported under VB, and will generate that error. The fix is to not
use
| > these controls.
| >
| > Do you use the data combo control along with its boundtext property?
This
| > will throw an error if the list is scrolled to view additional
items.
| There
| > is no fix.
| >
| > How long are the strings assigned to the array members (I'm
presuming the
| > array is defined as string, and not as a numeric data type). If
| significant,
| > remember that when you redim preserve VB creates a new array then
copies
| the
| > current array into it. This requires double the memory while these
two
| > arrays are alive.
| >
| > What is code where the error occurs, and on which specific line?
Include
| > declares and sample data.
| >
| > --
| >
| >
| > Randy Birch
| > MS MVP Visual Basic
| > http://vbnet.mvps.org/
| >
| >
| > "Tmenke" <me*****@netscape.net> wrote in message
| > news:1M***************@fe40.usenetserver.com...
| > : Hello,
| > :
| > : I was wondering if anyone can help. I wrote a program in VBA. It
does
| some
| > : calculations with matrices (arrays) . These arrays are dynamic and
are
| > sized
| > : according to a user defined input. The program works great when
woriking
| > : with a small number but as the number increases (estimate about a
50 x
| 50
| > : array) the program will give a runtime error 7 message "Out of
memory".
| 50
| > x
| > : 50 array does not seem like a lot and when I looked into the help
there
| > was
| > : a mention of a 64k segment boundary. I'm not sure what this is,
can
| anyone
| > : help explain this ?
| > :
| > : I was thinking this may be a limitation with running VBA on excel
and
| > wanted
| > : to compile a stand alone executable program that will take the
data
| placed
| > : in excel cell and do all the number crunching in the program. I
was
| hoping
| > : someone could help me with the syntax to set a constant in a VB
program
| > and
| > : set it equal to a cell or range in an excel spreadsheet (one that
is
| open,
| > : if this matters) and then write data to an excel range after
| calculations
| > : have been done.
| > :
| > :
| > : Thanks
| > :
| > :
| > :
| >
|
|
|


Jul 17 '05 #5
You might want to post some example code.

When does the error occur?

Try just dimensioning large arrays, without running any code on them.
How big can you get away with? Can you do ReDim MyArray(1000,1000)? Do
you get an error on the Redim statement? ( I don't).

Are you creating multiple copies of the array?

Are you calling a procedure recursively (a procedure calling itself),
creating a stack problem?

"Tmenke" <me*****@netscape.net> wrote in message
news:Mp****************@fe40.usenetserver.com...
| Could you give me some ideas on chasing down and debugging a problem
like
| this
|
|
| "Steve Gerrard" <my********@comcast.net> wrote in message
| news:1r********************@comcast.com...
| > I think you should sort out why you are getting an error with a tiny
| > array of 50 x 50 numbers. 2500 elements is peanuts. 500 x 500 should
be
| > no problem. 5000 x 5000, or 25 million elements, might be a problem.
| > There must be something else you are doing that is causing the
problem.
| >

| > | > : I was wondering if anyone can help. I wrote a program in VBA.
It
| > does
| > | some
| > | > : calculations with matrices (arrays) . These arrays are dynamic
and
| > are
| > | > sized
| > | > : according to a user defined input. The program works great
when
| > woriking
| > | > : with a small number but as the number increases (estimate
about a
| > 50 x
| > | 50
| > | > : array) the program will give a runtime error 7 message "Out of
| > memory".
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Frank Esser | last post: by
4 posts views Thread by Franklin Lee | last post: by
9 posts views Thread by Mike P | last post: by
22 posts views Thread by xixi | last post: by
14 posts views Thread by Alessandro Monopoli | last post: by
1 post views Thread by Nick Craig-Wood | last post: by
1 post views Thread by Jean-Paul Calderone | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.