Results 1 to 5 of 5

Thread: Code for ending programme

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Code for ending programme

    How do I implement code for ending the programme by clicking the cross at the upper left corner?

  2. #2
    mik706
    Guest
    I am not exactly sure what you mean, but if you put:
    Code:
    End
    this will close all the componants of the program.

  3. #3
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Using "End" will cause problems. You need to unload all forms and make sure all the objects you've reference or created are set to Nothing.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    I must have been misunderstood. I know that unload and end causes the programme to end, but what is the syntax do I use in the Terminat-procedure? I have used the code below, but the programme terminates, when I click the cross and then it asks me if I want to end.
    Code:
    Private Sub MDIForm_Terminate()
    Msg = "Do you want to end the calculations?"
    Style = 36
    Title = "Tester"
    
    Response = MsgBox(Msg, Style, Title)
    If Response = vbYes Then
       End
    End If
    End Sub

  5. #5
    Fanatic Member Mindcrime's Avatar
    Join Date
    Jun 2001
    Location
    Peterborough, UK
    Posts
    555

    ...or

    Code:
    Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
       Dim Msg   ' Declare variable.
       If UnloadMode > 0 Then
          ' If exiting the application.
          Msg = "Do you really want to exit the application?"
       Else
          ' If just closing the form.
          Msg = "Do you really want to close the form?"
       End If
       ' If user clicks the No button, stop QueryUnload.
       If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbNo Then Cancel = True 
    End Sub
    Mindcrime : )
    ICQ 24003332

    VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8

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