VB6: One MDI form instance limitation

Posted on 2004-04-20
Last Modified: 2012-05-04
I have a fairly complex project and need to instantiate more than one instance of the same MDI form at runtime. Is there any way to do this? The following works for SDI only.

Dim i As Integer
Dim frm As frmExplorer

For i = 1 to 5
    Set frm = New frmExplorer
    Call frm.Show
    Set frm = Nothing
Question by:dnhughes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 63 total points
ID: 10871344
There is only allow one instance of MDI form, you can create more that one instance of it..

Expert Comment

ID: 10871386
Are you trying to make more than one instance of the parent MDI form? Or of a child?

I just tried this code..

'This is the load procedure for the PARENT mdi form
Private Sub MDIForm_Load()
    Dim Frm1 As frmTEST
    Dim Frm2 As frmTEST
    Set Frm1 = New frmTEST
    Set Frm2 = New frmTEST
End Sub

I end up wtih 2 of the same form sitting as children in the mdi parent form..

Is this what you want?

Author Comment

ID: 10871646

  I'm trying to create multiple parent MDI forms
Private Sub cmdCreateWindows_Click()
    Dim frmMDI1 As frmMDITEST
    Dim frmMDI2 As frmMDITEST
    Set frmMDI1 = New frmMDITEST
    Set frmMDI2 = New frmMDITEST
    frmMDI1 .Show
    frmMDI2 .Show
End Sub
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.


Author Comment

ID: 10871913
The error that I'm getting is when I try to create a second instance is:
Run-time error '426':

Only one MDI Form allowed

Accepted Solution

LunaSkye earned 62 total points
ID: 10872095

This quote comes from VB Help:

"An application can have only one MDIForm object but many MDI child forms."

Maybe you could have multiple instances of your application?  or somehow move your functionality onto a child form?

Sorry im so general, i dont have alot of specifics to go on.


Expert Comment

ID: 10872962
For your information

I think
VB.Net allows multiple MDI Parents in an application.

LVL 52

Expert Comment

by:Ryan Chong
ID: 10875943
>>There is only allow one instance of MDI form, you can create more that one instance of it..
typo, sorry, shoud be:
There is only allow one instance of MDI form, you can't create more that one instance of it..

SSSoftware is right, create multiple MDI form is allowed in, example:

Dim f As MDIForm = New MDIForm()

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month5 days, 21 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question