Disposing the calling form

  • Thread starter Thread starter N! Xau
  • Start date Start date
N

N! Xau

HI,

my project's start object is a login form.
When login is successful, it opens a new form, with:

Dim CalledForm As New MyForm
CalledForm.Owner = Me
CalledForm.Show()

Now I want login form to disappear once CalledForm has opened.
Setting enabled / visible to true, form is still in memory and the
application does not close.
With Me.Dispose() into login form code, CalledForm closes too (not only
login form).

What is the right way?
Thanks

N! Xau
 
I would open both forms from the Sub Main procedure, which you can set to be
the startup object. Then, check the feedback from the Login form, before
deciding to the CalledForm.
 
or instead of doign calledform.show, call calledform.showdialog

the rest of the application will not continue executing until the user
has clicked on ok and the login form disposed of. You then have the
instance of the calledform in order to check any values the user has
added as input:

Dim CalledForm As New MyForm
CalledForm.Owner = Me
if CalledForm.ShowDialog() = dialogresult.OK
'Do your error checking for the correct password
end if

CalledForm.btnOK Pressed:
dialogresult = dialogresult.ok
me.close

CalledForm.btnCancel Pressed:
dialogresult = dialogresult.cancel
me.close
 
N

Don't make your login form your mainform.

There is not 'one' right way. I find this the nicest.

In a normal mainform you can set in the load event to show your login form.

A lot of people are writing that in the load event the form is not yet
showed, that is very nice because now you can do in that. (In a very
rudimentair way there is needed some more)

\\\
dim frmLogin = new formLoging
if frmLogin.show <> message.Ok then
then me.close
else
frmLogin.dispose
'normally a dispose is not needed however a showdialog is one of the
exceptions
end if

And your program stops if the login form not returns dialog.ok.

I hope this helps,

Cor
 
Back
Top