Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Dec 5, 1997

Checking to see if a MDI Form is open

Question:
I have an MDI application; when I Unload one form I want to check to see if another form is open and if it is run some code that refreshes it. I've tried using
if frmname.visible=true 
to see if its open but this doesn't work (it loads up the form if it isn't open). How do I check to see if a form is open?

Answer:
If the target form is loaded, it will be included in the Forms collection. In the Unload event of the first form, call a RefreshForm procedure that loops through the Forms collection and looks for the desired form. If it's there, refresh it:

   Private Sub Form_Unload(Cancel As Integer)
       Call RefreshForm(frmOne)
   End Sub

   Public Sub RefreshForm(frmTarget As Form)

       Dim frm As Form

       For Each frm In Forms
           If frm Is frmTarget Then
               ' Call your refresh
               ' code here
           End If
       Next

   End Sub
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date