form creation

Programming, for all ages and all languages.
Post Reply
nuno_silva_pt

form creation

Post by nuno_silva_pt »

Hi again!
I'm having a witle problem:
I'm seen some were that you can make something like:
dim nf as new form1
and if you put in the cmd1 event:
nf
then it creates a new form
BUT
When i do it it says:
Compile error: (something more)
how can i do this the right way??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
Tim

Re:form creation

Post by Tim »

What language are you using? What error do you see?
nuno_silva_pt

Re:form creation

Post by nuno_silva_pt »

visual basic
smartguy240

Re:form creation

Post by smartguy240 »

Im sorry but you are going about this the worng way

GO ahead and make the form in Visual Basic and have it in your project set the visible property to false. Also if it asks for the startup form, say the form that you want to load *first* under Sub_Main

THEN
in the cmd1's click event have the code

Code: Select all

frm1.show
and you can also say

Code: Select all

Unload Me
to hide teh first form...(the form that the cmd1 is on)

hope i helped ya!
nuno_silva_pt

Re:form creation

Post by nuno_silva_pt »

that's not it!
i want my program to use a MDI form and "create" a duplicated form
smartguy240

Re:form creation

Post by smartguy240 »

ok give me a few minutes and ill test this out for you...i think that i knwo how to do this and it should be easy
smartguy240

Re:form creation

Post by smartguy240 »

ok not as easy as i thought...prehaps if you give me an example of what you are trying to do

i dont know if this is possible in VB because Forms dont have indexes...this means that a Load Object(Index) wont work...in other cases like in adding extra objects to a form....you would say for example

Code: Select all

Load cmdButton(intIndex)
to add another to the for but the origonal button has to have an index specified as 0 to keep it as the origonal

this might work too...just make the form and if you want the properties to be the same as the other form then go

Code: Select all

cmd2.Caption = frm1.cmd1.Caption
or something to that effect

so if you can give an example i can probabally give ya an answer ;)
meelWORM

Re:form creation

Post by meelWORM »

Ok, first you want to create a MDI Form...
Project > Add MDI Form
name this frmMain

Then you want to create a MDI Child to open many copies from within the MDI Form(Parent)...
Just set the property of a normal form to MDIChild = True
name this frmSubTemplate

Now, you want to call many copies of this child...
In a Module, declare this:
Global frmSub(# of child's you want) as New frmSubTemplate

Then you can open new Child's like so:
frmSub(#).Show
It will open it as a Child of frmMain
smartguy240

Re:form creation

Post by smartguy240 »

yeah...he is right.... i knew about that...i just didnt know that that is what your problem was :-\

BTW: hey meelWORM...didnt know that you visited Mega Toyko!
meelWORM

Re:form creation

Post by meelWORM »

SMG: I just registered today! ;D
Eero Ränik

Re:form creation

Post by Eero Ränik »

Welcome to Mega-Tokyo! ;)
smartguy240

Re:form creation

Post by smartguy240 »

heheh thats great....the General Board is where i mostly hang out....but i also check the AGI board and this board *occasionally* to see if anyone needs any VB help ;)
nuno_silva_pt

Re:form creation

Post by nuno_silva_pt »

I finaly found what must i do!
you only write this:

Code: Select all

function newwindow()
dim nw as new formname
nw.show
end function
it works very well!
Post Reply