Results 1 to 12 of 12

Thread: [Resolved] Close All

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Resolved [Resolved] Close All

    Almost everytime i run my program then exit
    I'd look in the Task Manager, and see my program's name there

    How would I close the program and all of the forms
    or even end the process?
    Last edited by Hack; Mar 6th, 2006 at 06:56 AM. Reason: Added green "resolved" checkmark

  2. #2
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: Close All

    easy as this
    VB Code:
    1. formname.close
    or
    VB Code:
    1. Unload formanme
    noister
    <advertising link removed by moderator>

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Close All

    you can simply use the End command

    VB Code:
    1. End
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Close All

    VB Code:
    1. Dim frm As Form
    2. For Each frm In Forms
    3.     Unload frm
    4. Next
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Close All

    Best not use the End command since that won't free memory and stuff that your program was using.

    Also what do you mean by 'Almost every time' what do you normally do so it doesn't close?

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Close All

    I know how to close forms :P
    i've tried all of the examples above
    but when I close all of the forms, the process of the program is still running
    and the only way to exit is to go to the task manager

  7. #7
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Close All

    do you have an invisible form running?
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  8. #8
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: Close All

    try this code
    VB Code:
    1. 'Declaration
    2. Option Explicit
    3.  
    4. Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    5.  
    6. Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    7.  
    8. Public Const WM_CLOSE = &H10
    9.  
    10.  
    11.  
    12. 'Code
    13.  
    14. Public Sub CloseProgram(ByVal Caption as String)
    15.  
    16.  Handle= FindWindow(vbNullString, Caption)
    17.  If Handle = 0 Then Exit Sub
    18.  SendMessage Handle, WM_CLOSE, 0&, 0&
    19.  
    20. End Sub
    actually this code is to close an application... i hope it helps you... correct me if i'm wrong post
    Last edited by noielen; Mar 6th, 2006 at 01:06 AM.
    noister
    <advertising link removed by moderator>

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Close All

    yes, works like a lovely charm
    thank you

  10. #10
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: [Resolved] Close All

    how did you do it?
    noister
    <advertising link removed by moderator>

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: [Resolved] Close All

    you're CloseProgram() function

  12. #12
    Junior Member
    Join Date
    Mar 2005
    Posts
    19

    Re: Close All

    Dear friends


    I have gone through that condition. It is like miracle u see It happens soetimes only.....

    The Posibilities I found out was that there might be some of ur components or activex needs to be close I dont Know regarding your code. So I dont Know what type of the components ur using.

    One best Example is Connection whenever your application gets close u must close ur Connection so look to the components or activex types of stuffs u have used in your project
    Hemal N jivani
    Programmer
    India

    Mobile :-+91 99 24 11 88 01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width