Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VB6 is there something similar to DialogResult from a dialog?

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?

like image 608
Mike Webb Avatar asked Aug 03 '11 16:08

Mike Webb


People also ask

Is a form property that represents the result of the form when used as a dialog box?

Property Value A DialogResult that represents the result of the form when used as a dialog box.

What is ShowDialog in VB net?

ShowDialog() Shows the form as a modal dialog box.

What is DialogResult WPF?

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.


1 Answers

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.

like image 52
Deanna Avatar answered Nov 15 '22 10:11

Deanna