Click to See Complete Forum and Search --> : Creating new objects at runtime
SecretHell
March 7th, 2000, 02:10 PM
Hi,
How can I create new instances of a control on runtime ?
my main-control is named picture1
I tried something like this
dim p as object
set p = new picture1
.....
But this doesn't work.
Does anybody knows how I can make this work ?
Thanx
JimmyT
March 7th, 2000, 02:32 PM
The easiest way to do this is to ensure that your Picture1 control is assigned an Index Number (e.g. 0) when it is created. Then you can add or remove instances of the Picture1 by using
Load Picture1(Picture1.count)
The number of Picture1 objects is 1 when the program is started. The starting index is 0, so when this Load statement is encountered, the program will create Picture1(1). You can Unload controls that were created dynamically. You cannot Unload controls that were in existence at design time.
Good Luck...
Johnny101
March 7th, 2000, 02:36 PM
when you place a control on the form set it's index property to 0. then use something like this:
'assuming a textbox named txtControls
dim x as integer
x = ubound(txtControls) + 1
Load txtControls(x)
txtcontrols(x).visible = true
txtControls(x).Text = "I created this at runtime"
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.