Re: Programatically design a form
- From: "Peter T" <peter_t@discussions>
- Date: Thu, 7 Jul 2005 18:30:09 +0100
Patrick,
> Peter -
> MANY thanks for your reply. You've given me a bunch of
> ideas to think about and play around with. Could you answer
> another question or two for me?
>
> 1. Is the limit on the number of controls based upon EACH
> form in a VBA app? Can each form have, say, 256? Or,
> is that the limit for the entire app, regardless of number of
> forms?
AFAIK 256 per form. I don't know but might have problems if multiple forms
are loaded even if not Show'n. If you reference a form it will automatically
load into memory, which would occur if you copy controls from one form to
another - so would need to unload the dummy form when done.
> 2. If the limit from #1 is PER FORM, and I use your sug-
> gestions for copying/pasting pages at runtime, does the
> paste bring all the code along with the pasted page and
> its controls? If so, then maybe I could have a second,
> dummy form that holds the "to-be-loaded-at-runtime"
> pages (and their code). Then, depending upon which of
> my user groups is running the app, it could just insert th
> appropriate pages.
Just the controls, not the code can be copy/paste. Did you try the example I
referred you to with some sample code in the form?
Without knowing what commonality your pages and controls have it's difficult
to suggest the best approach. But I strongly suspect the "WithEvents Class"
method will serve you very well. Just one Event routine for all your
buttons, even 500 or even if you don't know how many in advance. This might
route to appropriate routines in normal modules depending on [say] which
button was clicked. Minimal code in your form, and no need to worry about
adding or copying code at runtime.
> 3. Finally, as I got started on this entire app as a stop-gap
> measure (and it has since grown into an app that is in use
> full-time by 30+ people), it is probably suffering from all
> kinds of problems due to my not releasing memory in the
> correct manner. Quite frankly, I don't understand how
> or when such things need to occur, and feel overwhelmed
> about how to even START on figuring this out.
Without any idea of what you are doing difficult to comment. In generall all
objects var's should be released when not needed, eg public vars stay in
scope when the app terminates, so set myOb = nothing first. BUT if you haved
used any like this:
Set oApp = Create(myApp)
Set oAppThing = oApp.Add some-App-thing
then release in this order
oAppThing.close
Set oAppThing = Nothing
oApp.Quit
Set oApp = Nothing
> Can you give me any advice for where to go for good
> info on determining if memory is being cleared correctly?
> Is that something as easy as looking to see how much
> memory is available, running and exiting an app, and re-
> checking how much memory is available? Or, do you
> use some third-party app that can "watch" your program
> run?
Off the top of my head I can't think where to direct you. Best avoid
problems in the first place. I suspect there are many in this group better
qualified to answer.
I can though recommend you to the .excel.programming group. It's obviously
geared to Excel but it's vast covering lots of generic vba, including your
issues. There are many there far more expert than I.
Explain your Multipage problem, be specific with some detail of what
commonality and differences there are between both pages and page controls,
eg buttons 10-10-20 of 50 on Page(0) do similar to buttons 10-20 of 50 on
Page(1) except .... I'll be surprised if you don't receive ideas and a good
example of how to create a WithEvents Class specific to your needs. Not sure
how many are familiar with the copy / paste controls method, so if
appropriate include a copy of the link I gave earlier with something like -
"I'm thinking of using the method described here to copy multipage pages +
controls".
Ask about releasing memory issues seperately though you would need to be a
bit more specific to get useful answers.
Good luck.
Now to turn to my own issues in this thread which I've barely begun to
address!
Peter T
.
- References:
- Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: J French
- Re: Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: Ken Halter
- Re: Programatically design a form
- From: Patrick Pirtle
- Re: Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: Patrick Pirtle
- Re: Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: Peter T
- Re: Programatically design a form
- From: Patrick Pirtle
- Programatically design a form
- Prev by Date: Re: Find Directory
- Next by Date: Re: VB, SQL & Word
- Previous by thread: Re: Programatically design a form
- Next by thread: Re: Programatically design a form
- Index(es):