Solved

MDI question

Posted on 2002-05-14
7
212 Views
Last Modified: 2010-05-02
Hi,

I am trying out my first MDI app and I have a question. In my main MDIForm, I am able to create multiple instances of a child form. Is there a way for me to iterate thru all of the child forms, regardless of how many are up? I want to be able to do this without keeping a static counter. Also, if anyone could point me to a good site that could enlighten me on the ins and outs of VB MDI's I would appreciate it.

Thanks
0
Comment
Question by:jhamlett
[X]
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
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7009424
dim x as form

for each x in forms
   msgbox x.caption
next
0
 
LVL 2

Accepted Solution

by:
ventond earned 100 total points
ID: 7009430
   Dim I As Integer

    For I = 0 To Forms.Count - 1
       If TypeOf Forms(I) Is frmMyForm Then
           Forms(I).ZOrder 0
       End if    
    Next

Where frmMyform is the name of the from you are looking for. You might also do something like:

if Forms(I).caption = "ME" then
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7009435
<<Is there a way for me to iterate thru all of the child forms, regardless
of how many are up?>> The way I do this is by using the forms collection.  I set the Tag property of all child forms to "child". For example I add a menu option under a Windows menu "Close all child windows".  The code looks like this:

Private Sub mnuWinCloseChild_Click()
Dim n as integer
On Error Resume Next
n=0
Do While n < Forms.Count
   If Forms(n).Tag = "child" Then
      Unload Forms(n)
   else
      n = n + 1
   End If
Loop
End Sub

Hope this helps...

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:trkcorp
ID: 7009447
PS: The reason the loop is While < Forms.Count is that Forms(1) will always be the MDI parent...
0
 

Author Comment

by:jhamlett
ID: 7009486
cool, those all work great. thanks for all the input.
0
 
LVL 4

Expert Comment

by:trkcorp
ID: 7009561
jhamlett, you should accept or reject the "forced" answer by ventond.  If you leave this question sitting here "locked" few people will bother to look at it and give you further input...  
0
 

Author Comment

by:jhamlett
ID: 7009897
my bad, thought I had accepted the answer, hehe
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

752 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