Visual Basic Coding Help
Moderator: Moderators
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
Visual Basic Coding Help
Is anyone here very familiar with Visual Basic? I've only been using it for about 4 or 5 months (I take a course in school). I know DC++ has a feature where if you press the X in the upper right corner it asks if you are sure you want to exit. I'm wondering if anyone here knows how to add a feature like that to a Visual Basic program. I'm using Visual Basic 6.0 if that matters. My teacher wasn't sure how to do it, she had a few ideas. The best I could do with her help was get a message box promt to come up, but both yes and no still would exit the program.
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 16:00
Dug up one of my old VB projects. Not 100 % sure it will work, but you can try.
Damn Guitarm...
Code: Select all
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim iYesno As Integer
iYesno = MsgBox("Sure you would like to close?", vbYesNo Or vbDefaultButton2, "Close?")
If iYesno = vbYes Then
Cancel = 0
Unload Me
ElseIf iYesno = vbNo Then
Cancel = 1
End If
End Sub
Damn Guitarm...
Last edited by ullner on 2005-01-12 21:53, edited 2 times in total.
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
ullner wrote:Dug up one of my old VB projects. Not 100 % sure it will work, but you can try.
Guitarm said he couldn't see the code, so here it comes without the code tag.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim iYesno As Integer
iYesno = MsgBox("Sure you would like to close?", vbYesNo Or vbDefaultButton2, "Close?")
If iYesno = vbYes Then
Cancel = 0
Unload Me
ElseIf iYesno = vbNo Then
Cancel = 1
End If
End Sub
Awesome, thanks a lot! Just what I wanted it to do.
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 16:00
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 16:00
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 16:00
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 20:38
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-27 03:14
- Location: Wisconsin, USA
Who is online
Users browsing this forum: Google [Bot] and 0 guests