Hi, I'm trying to get a return result from a MessageBox like this:
Clicking either the 'Yes' or 'No' button on the MessageBox always returns flag = True.
I've tried 'Dim flag As Boolean = False' and ran the code but still get 'True', so it's not just bypassing the code, it's actually setting flag to True.
The MsgBox title is 'Delete' as it ought to be, the correct question is being asked and the 'Warning' icon is being displayed.
I originally had ' flag = Windows.Forms.DialogResult.No' (i.e. without the CBool( ... ) but Option Strict insisted !.
Oh... and I've also tried 'flag = CBool(Windows.Forms.DialogResult.Yes)'... still with the same always 'True' result.
Poppa.
vb.net Code:
Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click Dim ask As String = "Are you sure you want to delete this record ?" Dim flag As Boolean = True MessageBox.Show(ask, "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) flag = CBool(Windows.Forms.DialogResult.No) If flag Then Exit Sub End Sub
I've tried 'Dim flag As Boolean = False' and ran the code but still get 'True', so it's not just bypassing the code, it's actually setting flag to True.
The MsgBox title is 'Delete' as it ought to be, the correct question is being asked and the 'Warning' icon is being displayed.
I originally had ' flag = Windows.Forms.DialogResult.No' (i.e. without the CBool( ... ) but Option Strict insisted !.
Oh... and I've also tried 'flag = CBool(Windows.Forms.DialogResult.Yes)'... still with the same always 'True' result.
Poppa.