vb.net - How can I return a value from a ShowDialog window? -


frmmain

dosomething() my.forms.frmmessage.showdialog(me) if acceptbuttonclicked ' code docode() else ' cancel button pressed doothercode() end if domore() 

frmmessage

my.forms.frmmain.acceptbuttonclicked = true 

is there way pass value dialog window paused thread on main window? want know if pressed ok or cancel button after filling out form pops up.

you can use dialogresult property on form. value returned showdialog function call. can set property on buttons winforms handle setting of form property.

in frmmessage you'll have set property accordingly (pick 1 need, ok , cancel). can check return value easily:

if my.forms.frmmessage.showdialog(me) = system.windows.forms.dialogresult.ok     ' ok button pressed     docode() else     ' cancel button pressed     doothercode() end if 

don't forget user might able close form in way closing buttons (e.g. closing close button).


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -