I am using vb 6.0
I am fairly new to VB, my question is:
On my main form I have a command button that has 40 procedures and it loops through them about 1,000 times and then exits. Nothing is passed and all of the variables are private.
I have one problem, memory. As it loops through the procedures, the memory taken up by the program keeps increasing. I have learned that the variables are not being cleared after the procedure ends and they are being kept in memory.
After googling for days, all I could find out was to use "an activeX"
Should I use "Active X exe" or "Active X dll"?

Well, it really depends on exactly what you are doing...

If you have something like this...

Procedure01 calls procedure02
Procedure02 calls procedure03
03 calls 04
04 calls 05
....

Then what you are doing is building up the stack space and thus you can see the memory expand.

However if you do something like this...

01 calls 02 and 02 returns to 01 (then pop off the stack it comes)
01 calls 03 and ....

then your memory will fluxuate up and down but not too seriously unless you keep building things up in memory... Meaning if you have lets say a string varible declared in the general declaration section of the form and your sub/functions keep adding to it.

So when you say your private variables are not being cleared when a sub is done, it leads me to belive that these variables are in the general declaration section.

Good Luck

The program is doing some number crunching, text manipulation, division, etc. An attempt at a lottery program. :-)

On my main form there is a richtextbox, and a button.
When the button is clicked, it goes through each sub and puts a line of text in the richtextbox to inform the user of it's progress.

The button:

Private sub cmdBegin_Click()
'''' gets the number of draws in the list (n) and loops (n) times
 x = 0
do until x = n
  GetDraw
  CheckDraw
  AnalyzeFirstNumber
  AnalyzeSecondNumber
  AnalyzeThirdNumber
  FineTuneFirstNum
  FineTuneSecNum
  AnalyzeRepeats
  ...
  OutputResults
  x = x + 1
loop
End Sub

I've only put 15 subs in so far, and I have at least 30 more. when I compile and run the program, the memory keeps climbing.
The variables are only declared private in each sub.
The coding is all in one form. (I have one form and one module)
The amount of lines in the form is roughly 12,000, should I be concerned on reaching the limit?
thx for the reply

from vb's help file...

Project Limitations


A single project can contain up to 32,000 "identifiers" (any nonreserved keyword), which include, but are not limited to, forms, controls, modules, variables, constants, procedures, functions, and objects. Note that the actual number of identifiers is limited to available memory.

Variable names in Visual Basic can be no longer than 255 characters, and the names of forms, controls, modules, and classes cannot be longer than 40 characters. Visual Basic imposes no limit on the actual number of distinct objects in a project.

So I don't think you should be worried yet...

However, I would suggest that you break up your code some and perhaps move some of your forms code to modules.

Good Luck

Oops, didn't realize I had to use Code Tags. I'll read the rules front to back this time.
Thanks vb5prgrmr. I'll move some of my code to the module.
One last question, how do I count how many identifiers I have so far in my program?

A single project can contain up to 32,000 "identifiers" (any nonreserved keyword), which include, but are not limited to, forms, controls, modules, variables, constants, procedures, functions, and objects. Note that the actual number of identifiers is limited to available memory.

Good Luck

This question has already been answered. Start a new discussion instead.