CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2007
    Location
    in your pocket
    Posts
    339

    [RESOLVED] Is the way i ending my program correct?

    Hai

    Code:
    Private Sub close_Click()
    Shell_NotifyIcon NIM_DELETE, t
     Dim MyForm As Form
     For Each MyForm In Forms
         If MyForm.Name <> "Form5" Then
            Unload MyForm
         End If
    Next
    End
    End Sub
    * form5 is the startup form.

    but i see still the process is running after close_Click
    ?
    "Don't Bring A Knife To A Gun Fight"

  2. #2
    Join Date
    Dec 2008
    Posts
    19

    Re: Is the way i ending my program correct?

    Try This:

    For i = Forms.Count - 1 To 0 Step -1
    Unload Forms(i)
    Next

    Remove the End command

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Is the way i ending my program correct?

    You aren't closing Form5 properly when you call END. That's why it doesn't end without it. This is the way to fire it. It closes the last OPEN form last.
    Code:
    Option Explicit
    
    Private Sub cmdExit_Click()
     Dim frm As Form
     For Each frm In Forms
       If frm.Name <> Me.Name Then ' Unload this form LAST
         Unload frm
         Set frm = Nothing
       End If
     Next
     Unload Me
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jul 2007
    Location
    in your pocket
    Posts
    339

    Re: Is the way i ending my program correct?

    Thank you for both Tom and dglienna :hello:
    for now ill go for dglienna's code,but toms one also alright
    "Don't Bring A Knife To A Gun Fight"

  5. #5
    Join Date
    Jul 2007
    Location
    in your pocket
    Posts
    339

    Re: [RESOLVED] Is the way i ending my program correct?

    hahaha, its funny, cant rep either of you boys
    "Don't Bring A Knife To A Gun Fight"

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] Is the way i ending my program correct?

    It won't work if you call it from another form.

    That's why I check for the last open form, then save it for the end.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2007
    Location
    in your pocket
    Posts
    339

    Re: [RESOLVED] Is the way i ending my program correct?

    Quote Originally Posted by dglienna View Post
    It won't work if you call it from another form.

    That's why I check for the last open form, then save it for the end.
    yah got it dglienna
    "Don't Bring A Knife To A Gun Fight"

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

Featured