I have a VB6 form with buttons with the text 'Continue' and 'Cancel'. I want to check which one was clicked. In C# every form has a dialog result and I could set it before exiting the form depending on which button was clicked. I don't see this in VB6.
Is there a dialog result? If not what is the best practice for checking the dialog result?
Property Value A DialogResult that represents the result of the form when used as a dialog box.
ShowDialog() Shows the form as a modal dialog box.
Posted on May 28, 2008 by marlongrech. In WPF Dialogs are quite different from Windows Forms. The behavior is still the same i.e when you have a Dialog opened (by calling the ShowDialog() method) the user must close the dialog in order to use the Window that opened the Dialog Window.
To simulate the .net WinForms behaviour, you will need a helper function in your form's code:
Public Function ShowDialog() As VbMsgBoxResult
Me.Show vbModal
ShowDialog = Iif(Cancelled, vbCancel, vbOk)
Unload Me
End Function
The form level Cancelled
variable can be set by the button event functions before calling .Hide()
or .Close()
, or you could have a variable containing the result code directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With