Solved

VB6: One MDI form instance limitation

Posted on 2004-04-20
7
1,373 Views
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
Next
0
Comment
Question by:dnhughes
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 50

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..
0
 
LVL 6

Expert Comment

by:LunaSkye
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
   
    Frm1.Show
    Frm2.Show
End Sub


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

Is this what you want?
-Andrew
0
 

Author Comment

by:dnhughes
ID: 10871646
ryancys
  How?

LunaSkye
  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
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:dnhughes
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
0
 
LVL 6

Accepted Solution

by:
LunaSkye earned 62 total points
ID: 10872095
DNHughes

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.

-andrew
0
 
LVL 4

Expert Comment

by:SSSoftware
ID: 10872962
For your information

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

Ed
0
 
LVL 50

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 vb.net, example:

Dim f As MDIForm = New MDIForm()
        f.Show()
        f.focus()
        f.BringToFront()
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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