Solved

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

Posted on 2002-03-04
4
2,418 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 50 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 56
vbModal 12 74
VBA - Excel, Hide/unhide range of rows on sheet with listbox selection 9 135
Macro problems with Excel file 6 52
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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

738 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