Moderator: Moderators
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 16:03
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 11:00
-
Contact:
Post
by ullner » 2005-01-12 16:29
Dug up one of my old VB projects. Not 100 % sure it will work, but you can try.
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...
![Razz :P](./images/smilies/icon_razz.gif)
Last edited by
ullner on 2005-01-12 16:53, edited 2 times in total.
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 16:44
Oh, invisible code?, nice concept
![Smile :)](./images/smilies/icon_smile.gif)
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 16:51
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.
![Smile :)](./images/smilies/icon_smile.gif)
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 16:54
Obviously my IE is......different, I can see the code with FF........
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 11:00
-
Contact:
Post
by ullner » 2005-01-12 16:54
Great.
![Smile :)](./images/smilies/icon_smile.gif)
Of course I'd like to get credit, but tell your teacher that you did it.
![Wink ;)](./images/smilies/icon_wink.gif)
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 16:58
You little......you.......I'm old but I'm not blind -
OK? ![Smile :)](./images/smilies/icon_smile.gif)
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 11:00
-
Contact:
Post
by ullner » 2005-01-12 17:01
Ah, pipe it you fat, bald, old man.
![Wink ;)](./images/smilies/icon_wink.gif)
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 17:03
ullner wrote:Great.
![Smile :)](./images/smilies/icon_smile.gif)
Of course I'd like to get credit, but tell your teacher that you did it.
![Wink ;)](./images/smilies/icon_wink.gif)
I'll tell her that I had some help.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
I could put a comment in my code thanking you.
-
ullner
- Forum Moderator
- Posts: 333
- Joined: 2004-09-10 11:00
-
Contact:
Post
by ullner » 2005-01-12 17:04
Hehe. You don't have to.
![Wink ;)](./images/smilies/icon_wink.gif)
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 17:04
I was looking at it through firefox and the code showed up perfectly (I saw it before you edited it to take out the code display).
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 17:04
Also tell her that If she needs a fat, blind old guy for a husband I'm here to help out
![Confused :?](./images/smilies/icon_confused.gif)
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 17:06
Guitarm wrote:Also tell her that If she needs a fat, blind old guy for a husband I'm here to help out
![Confused :?](./images/smilies/icon_confused.gif)
I don't think you want to live in Wisconsin...
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 17:11
Well, Wisconsin is probably a party compared to where I live now, trust me
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 17:12
Where do you live? (By the way right now its 35 degrees F and its raining and there is six inches of snow on the ground. Not that great of weather.)
-
Guitarm
- Forum Moderator
- Posts: 385
- Joined: 2004-01-18 15:38
Post
by Guitarm » 2005-01-12 17:13
Small town in Sweden, cold, icey, rainy. Ok, I'll stay here and you'll tell that nice teacher of yours she'll have to find someone else............
"Nothing really happens fast. Everything happens at such a rate that by the time it happens, it all seems normal."
-
Punkishlyevil
- Posts: 25
- Joined: 2004-02-26 22:14
- Location: Wisconsin, USA
Post
by Punkishlyevil » 2005-01-12 17:15
Guitarm wrote:Small town in Sweden, cold, icey, rainy. Ok, I'll stay here and you'll tell that nice teacher of yours she'll have to find someone else............
![Laughing :lol:](./images/smilies/icon_lol.gif)