Getting a result from a button

molemenacer

Active member
Joined
Jul 27, 2006
Messages
27
Location
Haywards Heath, UK
Programming Experience
Beginner
Morning all,

I have a button that when pressed calls a form

VB.NET:
[SIZE=2]
m_ApproveJobForm.Show()
[/SIZE]

There are two buttons on this form, OK and Cancel, and i am trying to test for which one has been clicked. I know i could use

VB.NET:
[SIZE=2]
m_ApproveJobForm.ShowDialog()
[/SIZE]

but it doesn't work the way i want it to (long story)

How can i check for a result in this case?

Thanks for any help
 
i use a boolean variable then set it to true when the OK button is clicked, otherwise it's false when the cancel button is clicked (or the form's X button is clicked)
 
You can set the DialogResult property of the button. You can also set the AcceptButton and CancelButton properties on the form to these buttons. You would then use code such as:

Dim dlgResult as DialogResult = myForm.ShowDialog()

You can then test for the dlgResult enumeration as to what was returned.

Lot's of ways to go about this.
 
Thanks for the help guys, but in the end i went another way.

The button was inside Word and clicking the button changes the status of the job. I used a different way that included passing control of the window to the form that is loaded by the button and carrying out the update and then using that to close the form and Word.

Thanks for the help anyway.
 
Back
Top