can anyone here plz help me with my porblem..

im using VB6, i want to display a message whenever the user will close the window..]
can anyone teach me how to code it..

Recommended Answers

All 5 Replies

Hi, Try to Write MessageBox Coding in Form_QueryUnload event or Form_Unload Event. This is will show the Message whenever user close the Window

Private Sub Form_Unload(Cancel As Integer)
Dim msg
msg = "Do you want to Exit? "
reply = MsgBox(msg, vbExclamation + vbYesNo)
Select Case reply
Case vbNo
Cancel = -1
Case vbYes
End
End Select
End Sub

tnx 4 the help, it realy works

Private Sub Form_Unload(Cancel As Integer)
     Dim msg

     msg = "Do you want to Exit? "
     reply = MsgBox(msg, vbExclamation + vbYesNo)

     Select Case reply
          Case vbNo
                   Cancel = -1
          Case vbYes
                   End
          End Select
End Sub

Make it short...

Private Sub Form_Unload(Cancel As Integer)
     If MsgBox("Do you want to exit?", vbQuestion + vbYesNo) = vbNo Then
               Cancel = -1
     End If
End Sub

have you any other question? If not then mark it solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.