Click to See Complete Forum and Search --> : Point to a form with a variable


Michelangelo
August 27th, 2001, 03:31 AM
I would like to be able to call a form and change it settings using a variable, something like


MyVar = "Form1"
MyVar.visible = true



This obviously doesn't work in this way. What can i do to accomplish this.

Cakkie
August 27th, 2001, 03:53 AM
You can do this using a form object

dim objForm as Form
set objForm = Form1
objForm.Visible = false




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Michelangelo
September 10th, 2001, 04:02 AM
This doesn't do the trick yet.
Your code:
dim objForm as Form
set objForm = Form1
objForm.Visible = false



Here Form1 isn't variable. What I want to do is to call the form with a variable name.

nm = "Form1"
set ObjForm = nm
ObjForm.Visible = true



When I declare dim nm as Form

then it doesn't work. So what I need is some declations of a variable to be able to point to a form.

Iouri
September 10th, 2001, 07:04 AM
Dim x as Form, strName as string
strName = Text1.Text
set x = Forms.Add(strName)
x.Show

Iouri Boutchkine
iouri@hotsheet.com

Michelangelo
September 10th, 2001, 07:20 AM
Thanx, but does this also work for a form which was created during design-time?

Cimperiali
September 10th, 2001, 07:30 AM
The Iouri solution requires that the form exists (means: it has been created in design time).

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Michelangelo
September 11th, 2001, 03:17 AM
Don't blame the ignorant for not knowing

Michelangelo
September 11th, 2001, 03:18 AM
Thanx, works perfectly

Cakkie
September 11th, 2001, 03:30 AM
We don't...

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Cimperiali
September 11th, 2001, 04:48 AM
I never do. Have a nice day.

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Michelangelo
September 14th, 2001, 08:33 AM
I've encountered another problem when using your suggestion. When i open de Form this way in runtime, it opens perfectly. But when calling a procedure in this form from another form or module a new window opens, which obviously isn't meant to.
My code looks like this

Sub Form1_Load()
Call OpenForms
Call EditText()
End Sub




Sub EditText()
Formauto1.Text1.Text = "SomeText"
End Sub




Sub OpenForms()
Dim x as Form, strName as string
strName = "Formauto1"
set x = Forms.Add(strName)
x.Show
End Sub




The form FormAuto opens correctly in the procedure OpenForms(). However it opens again when calling procedure EditText().

Any suggestions.