I have a simple program. When the user clicks the beginbutton a warningmessagebox pops up. If OK is clicked I want another (different) message box to pop up. I'm assuming I need to code the warningmessagebox click event? How do I do that? I've only double clicked on the object in design view and thats not an option. Thanks!
How to code message box click event?
Page 1 of 15 Replies - 5973 Views - Last Post: 21 October 2009 - 10:32 AM
Replies To: How to code message box click event?
#2
Re: How to code message box click event?
Posted 20 October 2009 - 04:57 PM
*Update
Ok, I have the 2nd message box popping up. This is my code thus far
Now I need to use a do/while loop to display the "WARNING!" messagebox 4 times. Can I use a do/while within an IF?
Ok, I have the 2nd message box popping up. This is my code thus far
Option Strict On
Public Class DeleteMainForm
Private Sub BeginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginButton.Click
Dim ResponseDialogResult As DialogResult
ResponseDialogResult = MessageBox.Show("Do you want to delete file?", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
If ResponseDialogResult = DialogResult.OK Then
MessageBox.Show("WARNING! It is dangerous to delete EXE file", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
End Class
Now I need to use a do/while loop to display the "WARNING!" messagebox 4 times. Can I use a do/while within an IF?
#3
Re: How to code message box click event?
Posted 20 October 2009 - 06:49 PM
You can repeat the If statement 3 more times or use a loop with a count down counter, however the multiple confirmations are BAD USER INTERFACE DESIGN. The users will count how many times and just keep hitting return without reading. Think about it - Windows provides the trash can that catches all deletions, so why should it ever ask me if I want to delete something when it is so easy to recover it? Answer is that it shouldn't, it should just move the file to the trash - even emptying the trash shouldn't require a confirmation as I had to do something special to even attempt that, not somehting accidental.
#4
Re: How to code message box click event?
Posted 20 October 2009 - 06:55 PM
mark.bottomley, on 20 Oct, 2009 - 05:49 PM, said:
You can repeat the If statement 3 more times or use a loop with a count down counter, however the multiple confirmations are BAD USER INTERFACE DESIGN. The users will count how many times and just keep hitting return without reading. Think about it - Windows provides the trash can that catches all deletions, so why should it ever ask me if I want to delete something when it is so easy to recover it? Answer is that it shouldn't, it should just move the file to the trash - even emptying the trash shouldn't require a confirmation as I had to do something special to even attempt that, not somehting accidental.
Thanks. I completely agree with you. However, this is homework and those are the directions. Below is what I came up with. I understand this code and it works but did I just get lucky? I'm new to loops.
Option Strict On
Public Class DeleteMainForm
Private Sub BeginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginButton.Click
Dim ResponseDialogResult As DialogResult
Dim ResponseTwoDialogResult As DialogResult
Dim ResponseInteger As Integer
ResponseDialogResult = MessageBox.Show("Do you want to delete file?", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Do While ResponseInteger <= 3
If ResponseDialogResult = DialogResult.OK Then
ResponseInteger += 1
ResponseTwoDialogResult = MessageBox.Show("WARNING! It is dangerous to delete EXE file", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
Loop
End Sub
#5
Re: How to code message box click event?
Posted 21 October 2009 - 01:18 AM
Hi first post here 
If you change it so that your loop is inside your If statement then it is more effiecient because if ResponseDialogResult does not equal DialogResult.OK it will not go through the whole loop as it is doing now
If you change it so that your loop is inside your If statement then it is more effiecient because if ResponseDialogResult does not equal DialogResult.OK it will not go through the whole loop as it is doing now
If ResponseDialogResult = DialogResult.OK Then
Do While ResponseInteger <= 3
ResponseInteger += 1
ResponseTwoDialogResult = MessageBox.Show("WARNING! It is dangerous to delete EXE file", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Loop
End If
#6
Re: How to code message box click event?
Posted 21 October 2009 - 10:32 AM
senoj, on 21 Oct, 2009 - 12:18 AM, said:
Hi first post here 
If you change it so that your loop is inside your If statement then it is more effiecient because if ResponseDialogResult does not equal DialogResult.OK it will not go through the whole loop as it is doing now
If you change it so that your loop is inside your If statement then it is more effiecient because if ResponseDialogResult does not equal DialogResult.OK it will not go through the whole loop as it is doing now
If ResponseDialogResult = DialogResult.OK Then
Do While ResponseInteger <= 3
ResponseInteger += 1
ResponseTwoDialogResult = MessageBox.Show("WARNING! It is dangerous to delete EXE file", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Loop
End If
Thanks, it does make more sense that way.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|