|
-
Aug 25th, 2009, 08:01 PM
#1
Thread Starter
Banned
[RESOLVED] Using vbNo and vbYes
How would I change it so that if a person clicked no, nothing happens?
Code:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (e.CloseReason = CloseReason.UserClosing) Then
MsgBox("Are you sure?", vbYesNo + vbQuestion, "Confirm")
If vbYes Then
Close()
If vbNo Then
End If
End If
End If
End Sub
End Class
-
Aug 25th, 2009, 08:03 PM
#2
Re: Using vbNo and vbYes
You know MsgBox is a function right?
-
Aug 25th, 2009, 08:06 PM
#3
Thread Starter
Banned
Re: Using vbNo and vbYes
 Originally Posted by ForumAccount
You know MsgBox is a function right?
But how do I make it not close?
-
Aug 25th, 2009, 08:10 PM
#4
Re: Using vbNo and vbYes
Why would you want to make it not close? That's kind of the point of the Msgbox, to make a message appear and you close it.
-
Aug 25th, 2009, 08:21 PM
#5
Re: Using vbNo and vbYes
if you mean how to stop the form from closing....
Code:
if vbNo then
e.Cancel = True
endif
however you really need to take a close look at your logic.....
vb Code:
If vbYes Then
Close()
If vbNo Then
End If
End If
using that code, the check for vbNo will no be done if No is selected.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Aug 25th, 2009, 08:27 PM
#6
Re: [RESOLVED] Using vbNo and vbYes
First, Msgbox() is not the proper format you'd use to do this. You would use Messagebox.show(), which has more power and manipulation than Msgbox(), which is just a wrapper.
Messagebox.show() is what you'd like to use to control YesNo operations, don't use old legacy vb code in a vb.net application.
-
Aug 26th, 2009, 09:20 AM
#7
Re: [RESOLVED] Using vbNo and vbYes
To sum up what the others are saying with an example:
Code:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (e.CloseReason = CloseReason.UserClosing) Then
If MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
e.Cancel = True
End If
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|