I have a form that has a button, when clicked it pops up a Dialog Form. Within this dialog form the user needs to select some data and when the user is finished they click the OK button. Once they click the OK button it needs to return an integer back to the previous form.
I created a Dialog Form and tried calling it via the code below:
Dim intResult as Integer = frmData.ShowDialog()
Debug.Writeline(intResult)
However, it seems I can only return DialogResults (Abort, Cancel, Ignore...)
I was wondering how I can try this without having to create a public variable and storing the result there.
Create a property on the Dialog that will return the value.
Create an event on your dialog form, subscribe to it on your main form, and raise it on your dialog with the appropriate data contained within the event arguments.
Create a cutom Dialog to your project(add/new element/Windows Forms/Dialog). Then create an instance from it, call showDialog and check if its DialogResult is Windows.Forms.DialogResult.Ok. You can access all of its controls, for example: