Thanks for replying. I found the information in my previous post wasn't
enough to tell you the entire picture ... so I think I should tell you a
little bit more about what I'm trying to do.
There are two forms in my program - namely Form 1 and Form 2. A button in
Form 1 opens Form 2, where the user is prompted to enter some information.
After the information has been entered, Form 2 is closed and the data
collected in Form 2 is used for some process in Form 1.
I'd like to know how can Form 1 detect that Form 2 has closed and it can
carry on.
There are two forms in my program - namely Form 1 and Form 2. A button in
Form 1 opens Form 2, where the user is prompted to enter some information.
After the information has been entered, Form 2 is closed and the data
collected in Form 2 is used for some process in Form 1.
I'd like to know how can Form 1 detect that Form 2 has closed and it can
carry on.
I tried but the code didn't work.
I inserted a breakpoint at the line where the 'Dim' statement occured.
In the debugging mode, I highlighted the 'DialogResult' statement to check
its value. 'None' appeared in a tooltip and the program skips the If block.
It seems that the program can't receive the input. How can I fix this?
You would have to tell if you use the showdialog or the show.
Herfried showed two samples.
When a form is showed with showdialog, than the mainform stops and wait
until the showdialog form is closed. And therefore those forms are forever
closed when they come back (not disposed)
When a form is showed with show than the mainform proceeds direct when that
is done.
You know nothing about the showed forms from inside your form where you
started the show, when you don't test that. While there is a slight time cap
between the closed state and disposed state from those forms when the user
has pushed the close button and the actions are done for that.
That can be tested with the second snippet in Herfried first answer to you.
I inserted a breakpoint at the line where the 'Dim' statement occured.
In the debugging mode, I highlighted the 'DialogResult' statement to check
its value. 'None' appeared in a tooltip and the program skips the If
block.
It seems that the program can't receive the input. How can I fix this?
Add an "OK" button to the form and assign it to the form's 'AcceptButton'
property. Alternatively you can set the form's 'DialogResult' property to
'DialogResult.OK' in a button's 'Click' event handler prior to closing the
form.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.