Sprocket46
asked on
MessageBox.YesNo
I have a delete button. Upon click of that button, I have a prompt for with a Yes/No option. I have the "Yes" button working, but the "No" still operates using the "Yes" function. How can I make it call or have it's own function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sounds like you want:
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
If MsgBox("Do you want to delete?", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.Yes Then
Do_Delete()
Else
Do_Cancel_Delete()
End If
End Sub
Private Sub Do_Delete()
'do stuff to delete something
End Sub
Private Sub Do_Cancel_Delete()
'do stuff to not delete something
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
If MsgBox("Do you want to delete?", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.Yes Then
Do_Delete()
Else
Do_Cancel_Delete()
End If
End Sub
Private Sub Do_Delete()
'do stuff to delete something
End Sub
Private Sub Do_Cancel_Delete()
'do stuff to not delete something
End Sub
ASKER
Thank you very much. Works great!
*******Code Begins here*********
if(confirm("Are you sure you want to delete?"))
{
//Code here if the option is 'OK'
}
*******Code ends here**********
I hope this works for you. All the Best