Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:29:39+00:00 2026-05-20T06:29:39+00:00

I am seeing code like Unload frmMain where from what I can tell frmMain

  • 0

I am seeing code like “Unload frmMain” where from what I can tell frmMain is the type/module name, and I don’t think it could also be simultaneously a variable name of the “ObjFrmMain” sort. Nevertheless, this command does successfully induce the form in question to unload.

So is the data type being used as an alias for its single existing instance? Or maybe for all of its instances?

Does VB6 do similar things to data types other than those derived from Form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:29:40+00:00Added an answer on May 20, 2026 at 6:29 am

    Yes, VB6 has odd object behavior. It gives you some shortcuts for dealing with form objects.

    Load frmMain
    

    …will load a single instance of that form under that variable name. In fact:

    frmMain.lblSomeLabel.Caption = "some caption"
    

    … will load that instance. However:

    frmMain.SomeStringMember = "some value"
    

    … will not load the form object (meaning the window itself) but you can access these variables, so in essence, the name of the form is a global variable.

    You can, however, create new instances:

    Dim newForm As MyForm
    Set newForm = New MyForm
    newForm.Show vbModal
    

    That will actually create a new instance of MyForm, load it and show it, so you can have multiple instances of one form.

    Also beware of the oddness in the New keyword:

    Dim newObject As New MyClass
    Set newObject = Nothing
    newObject.SomeStringProperty = "some value"
    

    This works without an “Object Reference Not Set …” error. When you declare a reference variable using the As New syntax, you can destroy the object by setting it to Nothing and then reference that variable again and it will create a new instance.

    In fact that’s what’s really going on with the forms. There is an implicit:

    Dim frmMain As New frmMain
    

    Personally I prefer not to use the As New syntax because it’s confusing and dangerous. It also has a performance penalty, vs. this:

    Dim newObject As MyClass
    Set newObject = New MyClass
    

    … but you’re stuck with it for the forms.

    What’s happening when you call Unload frmMain is that it unloads the window (and all the controls) so all the data in those are gone, but the object frmMain is still hanging around. Therefore even after you unload it, you can still access any member variables and properties. However, if anything references any control on the form, it will trigger an implicit Load frmMain. This is the source of a lot of subtle programming errors in VB6, especially when you’re trying to shut down.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen code like this (actually seeing another person type it up): catch
I have been seeing code like this usually in the start of header files:
While I'm going through Python code and seeing functions called, I notice things like
I think seeing the effect live is better than posting code here. So you
I'm seeing code like this inside of an erb template: <% hook :admin_footer_scripts do
I'm used to seeing old code like if (true) { ... } where it's
In this Java project I'm looking at, I keep seeing code with HashMap, like
In Android I am seeing code like this: public class Now extends Activity implements
I keep seeing code that does checks like this if (IsGood == false) {
I'm seeing some code I've inherited that looks like the following: @interface SomeClass (private)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.