Dynamic form creation 
Author Message
 Dynamic form creation

Hello,

Is Visual Basic 3.0 able to create on screen data entry forms
dynamically?

I know how to change the attributes of an object but how do I
create an instance of the object?

For instance, I press a button and another button gets created on
the form.

TIA,
weemeng



Sun, 10 Aug 1997 16:12:32 GMT  
 Dynamic form creation
FYI, as Chuck says search on the load command in VB help.  The technique
is rather simple.  You must first create at least one instance of a control
and set its index property to zero (therefore creating a one object control
array).  There after you can load an new instance of +that+ control with
the load command.

Regards,
Rob O'Neal



: >Subject: Dynamic form creation
: >Date: 22 Feb 1995 08:12:32 GMT

: >Hello,

: >Is Visual Basic 3.0 able to create on screen data entry forms
: >dynamically?

: >I know how to change the attributes of an object but how do I
: >create an instance of the object?

: >For instance, I press a button and another button gets created on
: >the form.

: Search online help for the LOAD command.

: ------------------------------------------------------------------------
: Chuck Stuart - Mesquite TX USA  
: VBTrace 2.00 is a runtime Procedure Trace/XReference/Debug/Profiler and
: much more tool for VB and is now in beta. Download beta version 2.00.10
: from ftp.apexsc.com/pub/cgvb/visitor.
: ------------------------------------------------------------------------

--
----------------------------------------------------
Robert O'Neal
Hunter Development, Inc.
- Helpdesk systems
Voice: (800) 435-5954 (708) 437-2717 Fax: (708) 437-2683



Tue, 12 Aug 1997 13:19:01 GMT  
 Dynamic form creation
Quote:

>  Hello,

>  Is Visual Basic 3.0 able to create on screen data entry forms
>  dynamically?

>  I know how to change the attributes of an object but how do I
>  create an instance of the object?

>  For instance, I press a button and another button gets created on
>  the form.

>  TIA,
>  weemeng

Hi,

The answers to your two questions are
slightly different.

A. To load a new instance of a control,
you can use a control array (see the
Load statement).  A couple of potential
gotchas here:

1. You must have created the first instance
of the control at design time,

2. New instances come up invisible, and

3. They all appear in exactly in the same
location

So most useful code moves the new instances
and make them visible.

B. To load a new instance of a form, you can
use the Set statement.  Assuming you want
another instance of Form1, this code will
do it.

Dim Form2 as Form ' Dim or Global in a declarations area,
                  ' or use Static within
                  ' a procedure

Set Form2 = New Form1
Form2.Tag = "Form2"

As usual, a couple of gotchas.

1. All these instances use the same event
   handlers.  If you try to put the above
   code in the FormLoad event, the first
   thing you'll notice is that control
   appears to jump back to the start of
   the event handler.  That's because you're
   getting a FormLoad event on the new
   instance.  So I suggest *not* putting
   the above code in the FormLoad event.

2. I have yet to find an easy (i.e, without
   getting into the APIs) way to get
   at the name of a form from within VB
   code.  (If anyone has one, please clue
   me in.)  So I use the Tag property to
   keep the name.  Then my event handler
   can use the Tag to handle any instance
   in the same way that control array
   event handlers use the Index property.

If you omit the New keyword, you'll find
that you have created something like an
alias: you'll have only one form that you
can access by more than one name.

Hope this helps.

Reg Jacklin
Contract Programmer



Wed, 13 Aug 1997 00:45:21 GMT  
 Dynamic form creation

Quote:

>Subject: Dynamic form creation
>Date: 22 Feb 1995 08:12:32 GMT
>Hello,
>Is Visual Basic 3.0 able to create on screen data entry forms
>dynamically?
>I know how to change the attributes of an object but how do I
>create an instance of the object?
>For instance, I press a button and another button gets created on
>the form.

Search online help for the LOAD command.

------------------------------------------------------------------------
Chuck Stuart - Mesquite TX USA  
VBTrace 2.00 is a runtime Procedure Trace/XReference/Debug/Profiler and
much more tool for VB and is now in beta. Download beta version 2.00.10
from ftp.apexsc.com/pub/cgvb/visitor.
------------------------------------------------------------------------



Sun, 10 Aug 1997 17:48:09 GMT  
 Dynamic form creation

Quote:

>Hello,

>Is Visual Basic 3.0 able to create on screen data entry forms
>dynamically?

>I know how to change the attributes of an object but how do I
>create an instance of the object?

>For instance, I press a button and another button gets created on
>the form.

>TIA,
>weemeng

Hi There,

I got really good at this one while I was at my last contract...

Create the control...
In the index property, set the index of the first control to 0 or some other number...
In you program, use the following code

Sub Rebirth_Click()
   Dim n as Integer
   n=1
   Load ControlName(n)
   ControlName(n).Visible=True
   ControlName(n).Left=1000
   ControlName(n).Top=560
End Sub

For form arrays use this code...

GLOBAL.BAS

Global FormName(n) as new frmOriginalForm     'where n is some constant to the maximum number of forms you want

MYPROG.BAS

Sub Rebirth_Click()
   Load FormName(1)
   FormName(1).Left=1000
   FormName(1).Top=2000
   FormName(1).Show
End Sub

Regards
________________
Adrian Hum
Tessaract Productions.
"Can we trust out public figures any more?
   One week they're on the cover of TIME,
   and next week they're doing it..."



Tue, 19 Aug 1997 05:03:15 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Dynamic Form Creation

2. Dynamic Forms Creation on the Fly

3. Dynamic Form Creation

4. Dynamic Form creation?

5. Runtime Creation of Dynamic Forms

6. Dynamic Control Creation - Expand Form?

7. Dynamic Creation of Object Names - Forms

8. Form dynamic creation

9. Grabbing stuff from form / dynamic variable creation (?)

10. dynamic form name creation

11. Form Dynamic property , app Dynamic property ?

12. Accessing Dynamic Controls on Dynamic Forms

 

 
Powered by phpBB® Forum Software