Hi all, How do I load, or call a form from a module?
Rudy
Printable View
Hi all, How do I load, or call a form from a module?
Rudy
Something like this?
VB Code:
Dim f as New Form1() f.Show()
Does that create a new form or load the form called form1?Quote:
Originally posted by Mike Hildner
Something like this?
VB Code:
Dim f as New Form1() f.Show()
The first line does a couple things. It Dim's a variable named f as a type Form1. It also instantiates an instance of the class Form1, by calling the default, no argument constructor, and assigns that instance to the variable f.
The second line shows the form. This would cause the form to fire it's Form1_Load method.
Could also be written like this:
VB Code:
Dim f as Form1 f = New Form1() f.Show()
Ok.. Got it so far by changing the form name to the form I have.. (Don't know why but I was confusing my self with that) with this code:Quote:
Originally posted by Mike Hildner
The first line does a couple things. It Dim's a variable named f as a type Form1. It also instantiates an instance of the class Form1, by calling the default, no argument constructor, and assigns that instance to the variable f.
The second line shows the form. This would cause the form to fire it's Form1_Load method.
Could also be written like this:
VB Code:
Dim f as Form1 f = New Form1() f.Show()
VB Code:
Public Sub Main() Dim Splash As New Splash Call Splash.Show() End Sub
Only problem is that the program ends right away and I only see the form for a brief second.. In VB6 I would do this:
VB Code:
splash.show vbmodal
What is the equivilent to that in .NET?
use a ShowDialog to show it modal. Also, I don't recommend you name your object the same as the class, that is confusing. At least call it oSplash
Dim oSplash as Splash
I agree with that.. I only did it for a quick reference..Quote:
Originally posted by SeanGrebey
use a ShowDialog to show it modal. Also, I don't recommend you name your object the same as the class, that is confusing. At least call it oSplash
Dim oSplash as Splash
Thanks for the ShowDialog.. That is exactly what I was looking for..
Kind of irratating that I have to reference the form like that.. I liked it in VB6 where I create the form and then just call it anyplace.. :(
Thanks again for the help guys!
:D:D
VB6 actually created the reference for you behind the scenes, that's why you could do it in VB6. But that's really kind of sloppy and goes against things like encapsulation.