Click to See Complete Forum and Search --> : THE WIZARD! Is making classes or objects???? Please help . . . the wizard, I ended up with . . .


John Reynolds
June 25th, 2001, 03:53 PM
When I used the wizard to help make an app, I ended up with a splash screen and a main form . . . (frmSplash and frmForm). Are these classes or objects?

For example, it seems as though the frmMain is a class since the wizard used New to instantiate fMainForm. But why didn't the wizard use New to instantiate a splash object? It just called it's Show method. Why? Is frmSplash an object and frmMain a class? How can you tell? Thanks for any help.


frmSplash.Show
frmSplash.Refresh
set fMainForm = new frmMain
Load fMainForm
Unload frmSplash
fMainForm.Show




. . .

CodeBlue
June 25th, 2001, 08:58 PM
When a form (of any kind) is added to your project, it is a CLASS. It becomes an OBJECT when it is first instantianted. A form can be instantiated implicitly (by referencing it) or explicitly (by using the New keyword). In your case, here's how it works:


Class Name Instantiation Object Name
---------- ------------- -----------
frmSplash Implicit frmSplash
frmMain Explicit fMainForm




They both accomplish the same thing, but frmSplash uses a "hidden global variable" for the form. The advantage of using implicit instantiation is that it is EASY and doesn't require the creation of a separate variable to hold a reference to the form object. The disadvantage is that it is harder to manage the form's lifetime and memory resources. In the VB help, there's an excellent article called "Life Cycle of Visual Basic Forms" that explains it in detail, but you may have to read it 3 or 4 times before it makes sense.

Good luck,
Brent