Forms

A

ats@jbex

In a project I have a Module mMain. At program shutdown I call a procedure
here that will check for any open forms and close them as follows:

Sub CloseAllForms()

Dim f As Form

For Each f In Forms
If f.Name <> "frmMenu.vb" And f.Name <> "frmStatus.vb" Then
f.Close()
End If
Next

End Sub

The problem I have is that I am getting an error message saying that "Name
'Forms' is not declared". What do I need to do to get this code to work?

TIA

--
ats@jbex

I'm not gonna be taken in
They said if I don't join I just can't win
I've heard that story many times before
And every time I threw it out the door

SLF - Wasted Life
 
T

Tom Shelton

In a project I have a Module mMain. At program shutdown I call a procedure
here that will check for any open forms and close them as follows:

Sub CloseAllForms()

Dim f As Form

For Each f In Forms
If f.Name <> "frmMenu.vb" And f.Name <> "frmStatus.vb" Then
f.Close()
End If
Next

End Sub

The problem I have is that I am getting an error message saying that "Name
'Forms' is not declared". What do I need to do to get this code to work?

TIA

--
ats@jbex

I'm not gonna be taken in
They said if I don't join I just can't win
I've heard that story many times before
And every time I threw it out the door

SLF - Wasted Life

What version of VB.NET are you using? In 2005, you can use My.Forms.
Before that... There is no such thing.
 
J

Jan Hyde (VB MVP)

"ats@jbex" <[email protected]>'s wild
thoughts were released on Tue, 23 Oct 2007 07:39:44 GMT
bearing the following fruit:
In a project I have a Module mMain. At program shutdown I call a procedure
here that will check for any open forms and close them as follows:

Sub CloseAllForms()

Dim f As Form

For Each f In Forms
If f.Name <> "frmMenu.vb" And f.Name <> "frmStatus.vb" Then
f.Close()
End If
Next

End Sub

The problem I have is that I am getting an error message saying that "Name
'Forms' is not declared". What do I need to do to get this code to work?

Take a look at My.Application.OpenForms
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top