VB icon

Check if your MDI Child form is already loaded

Email
Submitted on: 1/3/2015 6:47:00 PM
By: rhai (from psc cd)  
Level: Beginner
User Rating: By 5 Users
Compatibility: VB.NET
Views: 8368
 
     Checks for other instances of your form on your Parent MDI form. If one is found, load that one. Else, Load a new one! The other example is too long and requires a lot of work, while this one is easy doesnt require you to catch an error. This is my own work, and i'll share it to all ot you!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Check if your MDI Child form is already loaded
// Description:Checks for other instances of your form on your Parent MDI form. If one is found, load that one. Else, Load a new one!
The other example is too long and requires a lot of work, while this one is easy doesnt require you to catch an error.
This is my own work, and i'll share it to all ot you!
// By: rhai (from psc cd)
//
// Inputs:ShowForm(new <form>)
<form> -> the Name of your form
//
// Returns:nothing
//
// Assumes:fMain -> the Name of your MDI Form
//
// Side Effects:nothing
//**************************************

	Private Sub ShowForm(ByVal fForm As Form)
		Dim objForms As Form
		For Each objForms In fMain.MdiChildren
			If objForms.Name = fForm.Name Then
				fForm.Dispose()
				fForm = Nothing
				objForms.Show()
				objForms.Visible = True
				objForms.Focus()
				Return
			End If
		Next
		With fForm
			.MdiParent = fMain
			.Show()
		End With
	End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.