views:

718

answers:

1

I have a message box with YesNoCancel button..

Pressing Yes will do some action and close the app - works fine, Pressing No will do nothing and close the app - (see below), Pressing Cancel will Do nothing and keep the app open - (see below).

I'm using DialogResult.No for No button and DialogResult.Cancel for cancel button. But pressing either of them triggers DialogResult.Cancel event. Whats the problem?

+3  A: 

This should work fine:

Dim result = MessageBox.Show("message", "caption", MessageBoxButtons.YesNoCancel)
If result = DialogResult.Cancel Then
    MessageBox.Show("Cancel pressed")
ElseIf result = DialogResult.No Then
    MessageBox.Show("No pressed")
ElseIf result = DialogResult.Yes Then
    MessageBox.Show("Yes pressed")
End If
Darin Dimitrov
Darin,Bibhas, this seems like the correct answer.
astander
Ohkay, got my mistake.. Thanx.. ^_^
Bibhas