CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2000
    Posts
    200

    THE WIZARD! Is making classes or objects???? Please help . . . the wizard, I ended up with . . .

    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




    . . .


  2. #2
    Join Date
    Mar 2000
    Posts
    145

    Re: THE WIZARD! Is making classes or objects???? Please help . . . the wizard, I ended up with .

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured