Sign in to follow this  
BloodLust666

MDI with VB 6

Recommended Posts

i'm just starting to get into MDI projects and i was wondering what are all the facts about having an MDI documents. like will the "dim" variables in the MDI document have scope in the child documents or vice versa, can the global variables in a module be changed in the MDI document and child document, etc. thank you

Share this post


Link to post
Share on other sites
If you have an MDI container form, and declare local/member variables in there, no, the child forms do not automatically gain access to these variables. VB6 only allows one MDI form to exist at any point in time, so it's easy to know which MDI contains any child form. Thus you can add functions to get/set these variables, or better yet, provide an actual interface.


Global variables in a module can be indeed changed anywhere [smile]


In an MDI child form, each child form gets its own set of member variables. If you've used an Object Oriented Programming Language before, it's best to think of the name of the form as a class rather than an object.

In a simple VB application, you might write:

Form1.Text1.Text = "DGF"

this shows that Form1 can be treated as an object. But you can have more than one Form1:

Dim Form1Instance1 As New Form1
Dim Form1Instance2 As New Form1
Form1Instance1.Text1.Text = "SIX FIVE FIVE THREE SIX"
Form1Instance2.Text1.Text = "FIVE NINER OH FOUR EIGHT"
Debug.Assert Form1Instance2.Text1.Text <> Form1Instance1.Text1.Text

in this case, each instance of Form1 has its own set of controls, member variables, etc.

[Edited by - MrEvil on April 2, 2006 9:57:49 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this