Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new form from scratch in a user control 1

Status
Not open for further replies.

zggs90

Programmer
Sep 3, 2001
58
GB
I have developed a user control and want to create a new form on occasions to display a picture.

Is it possible to create a new form on the fly?

Thanks

Geoff
 
Yes. Create the form in your project, set all of it's properties and such the way you want them. Let's say it's named frmPicture.

You then create a new instance of the form by assigning it to an object variable.

Dim MyPictureForm as frmPicture
Set MyPictureForm = New frmPicture

And then you can show it or whatever you want to do, by referring to the object variable.

MyPictureForm.Show vbModal

and so on...

This way you can have multiple instances of the form open at one time.

If you need to capture events from these forms ( keypress, clicks, etc. ) then it becomes a little more complex.

Hope this helps,

Robert
 
hmmmmmmmmmmmmmm ... mmmmmmmm,

nothing actually wrong with creating it statically, but it really doesn't directly respond to the question actually asked.

use 'advanced' search witth "createform" (or "createform") as the keyword. both are found in htese fora, and some entries include procedures to create a form (report), populate it with controls, set a recorrd source and display it.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Well, since he said all he wanted to do was to show a picture, I thought that doing it statically was probably the easiest way for him. If it was something more like "I want a form that has fields for entering data, and the fields change depending on X", then I would have suggested something along those lines.

Robert
 
Thank you both for your responses, I have tried the first solution and it works ok but really want to create the form as addressed by Michael Red, but have been able to get any response in advanced search as copied below:

use 'advanced' search witth "createform" (or "createform") as the keyword. both are found in htese fora, and some entries include procedures to create a form (report), populate it with controls, set a recorrd source and display it.

But what does "htese fora" mean?

Thanks once again
 
He means to do a search in "This Forum", in other words, the VB5 & 6 forum.

Robert
 
Actually, I meant Tek-Tips. I'm not sure if the procedure is posted in VB or Ms. A.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top