Solved

CLOSING FORMS IN VB

Posted on 2003-11-16
13
342 Views
Last Modified: 2010-04-17
how to close all opened forms in VB at time?
0
Comment
Question by:kalyani_g
  • 3
  • 2
  • 2
  • +4
13 Comments
 
LVL 8

Expert Comment

by:SNilsson
ID: 9758159
Dim x as form

For each x in forms
   unload x
Next
0
 

Expert Comment

by:qwertykeyboard
ID: 9758304
There are 2 possibilities. You can:

unload form?

that will close the form HOWEVER... this will hide the form:

form?.hide

Good Luck
0
 

Expert Comment

by:qwertykeyboard
ID: 9758311
If you have hundreds of forms, then you might not want to use either of those possibilities!!!
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 9758466
If he have hundreds of forms, he have a design problem.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9758786
Why is having hundreds of forms a design problem?

mlmcc
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:SNilsson
ID: 9758885
Well, hundreds of open forms then... imagine the poor user's when he look at the interface, I cant see any situation where it would be neccesary to have hundreds of forms, instancing one form a hundred times, that I could understand.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9761358
If you mean all open at the same time I agree.  We have an application with nearly 100 forms each with a specific purpose and there is no confusion since generally only one or two are open at a time.

mlmcc
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9761726
close or hide?
or you want to make sure the application exits when the form is close irrespective of some forms being open?
if its the last ie u wnat the app to quit irrespective of some forms being open on the main use END
0
 

Expert Comment

by:deepakshi
ID: 9777003
See, you may write code as

public sub CloseAll()
    Dim i As Integer
   
    Dim x As Object
   
    For i = Forms.Count To 1 Step -1
       
        Set x = Forms(i - 1)
        Unload x
        Set x = Nothing
       
    Next

End Sub

Hope it helps.
0
 
LVL 3

Expert Comment

by:Phoenixric
ID: 10937279
Please proceed. . .

As a suggestion, closing a form, even a hundred or so can be done without a coding . If and only if you have design it to have a parent form or MDIform. The other forms MDIChild property should be set to true. Unloading the parent form will automatically unload all open child forms. . .leaving independent forms still running if the author wants it that way. (Abcourse avoiding END command in the parent form)

Another thing is that the author did not mentioned closing all open forms without ending the application. .  So whats the problem? Invoking END command will automatically close all open forms then End the application. Anyway the author might need to elaborate further his question. . Sorry if I misunderstood.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 11188525
PAQed - no points refunded (of 20)

CetusMOD
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
linearIn  challenge 23 65
countX 22 70
groovy example issue 10 70
autoit - check if option is checked in another program 2 71
A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now