Closing a form

J

john wright

My program requires users to login before use. Using the following code in
the login form:

Me.Opacity = Me.Opacity - 0.2
If Me.Opacity <= 0 Then

Timer1.Enabled = False

If boolExit = False Then

My.Forms.frmMain.Opacity = 0

My.Forms.frmMain.Visible = True

Else

Me.Close()

Application.Exit()

End If

End If

I fade out the login form, and fade in the main form. However if I call
me.close() in the loop that turns on the opacity for the main form the whole
program shuts down. So in the main form I put in the following code:

Me.Opacity = Me.Opacity + 0.1

If Me.Opacity >= 1 Then

Me.Opacity = 1

Timer1.Enabled = False

My.Forms.frmLogin.Dispose()

End If

When I dispose of the form after loading the main form (in the timer event)
or call the My.Forms.frmLogin.Close() method it shuts down the whole
program. How can I just unload the login form?

Thanks.

John
 
C

Chris

john said:
My program requires users to login before use. Using the following code in
the login form:

Me.Opacity = Me.Opacity - 0.2
If Me.Opacity <= 0 Then

Timer1.Enabled = False

If boolExit = False Then

My.Forms.frmMain.Opacity = 0

My.Forms.frmMain.Visible = True

Else

Me.Close()

Application.Exit()

End If

End If

I fade out the login form, and fade in the main form. However if I call
me.close() in the loop that turns on the opacity for the main form the whole
program shuts down. So in the main form I put in the following code:

Me.Opacity = Me.Opacity + 0.1

If Me.Opacity >= 1 Then

Me.Opacity = 1

Timer1.Enabled = False

My.Forms.frmLogin.Dispose()

End If

When I dispose of the form after loading the main form (in the timer event)
or call the My.Forms.frmLogin.Close() method it shuts down the whole
program. How can I just unload the login form?

Thanks.

John


You need to start your program outside of the login screen. The way I
do it is to start the program in a "sub main" then show the login form
from there.

sub main
dim L as Login
if L.Showdialog = DialogResult.ok then
L.DoFadeOut
dim M as Main
M.ShowDialog
else
'Login Failed
end if


end sub
 
C

Cor Ligthert [MVP]

John,

Boni,

Why not as simple as this (typed here watch typos) in the load_form of your
mainform

\\\\
dim mylogin as new LoginForm
me.visible = false
if myLogin.showdialog <> dialogresult.ok then 'or whatever
me.close
end if
myInformationFromTheLogin = mylogin.ThePublicPropertyOrValue
me.visible = true
myLogin.dispose
///

I hope this helps,

Cor
 

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.

Ask a Question

Top