GrahamAtJobserve
asked on
How to tell if a form is loaded in VB.Net
I'm just upgrading to vb.net from vb6. In vb6 I had a great function that would tell me if a form was loaded. However, theres *no* equivalent to the forms collection.
I'd appreciate being able to keep my function paramter the same (form name as a string) but this isn't essential.
Any ideas folks?
'************************* ********** ********** ********** **
'** FUNCTION: IsFormLoaded
'** DESCRIPTION: Test if a form is loaded
'**
'** PARAMETERS: Form name (string)
'**
'** RETURN: true or false
'************************* ********** ********** ********** **
Public Function IsFormLoaded(ByVal s_FormName As String) As Boolean
Dim i_FormCount As Integer
Dim t As Integer
s_FormName = LCase(s_FormName)
i_FormCount = Forms.Count
For t = 0 To i_FormCount - 1
If LCase(Forms(t).Name) = s_FormName Then
IsFormLoaded = True
Exit Function
End If
Next t
'* must be false
IsFormLoaded = False
End Function
I'd appreciate being able to keep my function paramter the same (form name as a string) but this isn't essential.
Any ideas folks?
'*************************
'** FUNCTION: IsFormLoaded
'** DESCRIPTION: Test if a form is loaded
'**
'** PARAMETERS: Form name (string)
'**
'** RETURN: true or false
'*************************
Public Function IsFormLoaded(ByVal s_FormName As String) As Boolean
Dim i_FormCount As Integer
Dim t As Integer
s_FormName = LCase(s_FormName)
i_FormCount = Forms.Count
For t = 0 To i_FormCount - 1
If LCase(Forms(t).Name) = s_FormName Then
IsFormLoaded = True
Exit Function
End If
Next t
'* must be false
IsFormLoaded = False
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Per recommendation, force-accepted.
Netminder
CS Moderator
Netminder
CS Moderator
In VB.net 2005 I do this. It also checks to see if it is minimixed and if it is I restore it first.
Private Sub OnTimePerformanceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OnTimePerformanceToolStripMenuItem.Click
If frmOnTime.CanFocus = True Then
If frmOnTime.WindowState = FormWindowState.Minimized Then
frmOnTime.WindowState = FormWindowState.Normal
End If
frmOnTime.Focus()
Else
frmOnTime.Show()
End If
End Sub
close this question after seven days, with the following recommended
disposition:
Points to kprestage
If you have any comment or objection to the recommendation, please leave it here.
guidway
EE Cleanup Volunteer