Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to tell if a form is loaded in VB.Net

Posted on 2002-03-04
4
Medium Priority
?
2,428 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:GrahamAtJobserve
[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
4 Comments
 
LVL 9

Accepted Solution

by:
kprestage earned 200 total points
ID: 6839175
In order to get the functionality of the Forms collection in .Net, you will need to implement your own Forms collection.  Basically, you will need a global Collection called Forms.  In each of your forms Contructor method, you would need to add the form to the forms collection.  In each dispose method, you would need to remove the form from the collection.  Wish I had a better answer for you, but this is the only way around this that I have heard of!

0
 
LVL 12

Expert Comment

by:guidway
ID: 7306304
This question appears to have been abandoned. A Moderator will be asked to
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
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7331666
Per recommendation, force-accepted.

Netminder
CS Moderator
0
 

Expert Comment

by:sqdperu
ID: 33212568
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

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

715 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