By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

Closing as Form

P: n/a
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password another
form opens.

How do I close the login form?
Can any body help me!
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hi,
Hide the login form (after successful logon) and show the main form using
ShowDialog() method (assuming logon form is the startup form).
Or, show the logon and main forms indepenantly (from Sub Main()). That is,
show the logon form using ShowDialog and based on the dialog result (eg:
DialogResult.OK for successful logon), close the logon form and show the
main form using Application.Run().

HTH.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password another
form opens.

How do I close the login form?
Can any body help me!

Nov 21 '05 #2

P: n/a
Partha,

It is always difficult to see how people start there programs, so in
addition to Shiva, when I use a login form I start the login form in the
load event of my main form. (Did you already look at rollbased integrated
security by the way, than it can be that the login form is not needed).

However directly your question.

dim f as new loginform
f.showdialog
password = f.password
f.dispose.

I hope this helps?

Cor
Nov 21 '05 #3

P: n/a
Hello Shiva,

Thank you for your answere

But my code is shown below, which is written in the button_Click procedure
block

Dim MainFrm As New frmMain

MainFrm.Show()

Dim LoginFrm As New frmLogin

LoginFrm.Hide()
frmLogin is the StartUp object, on successfully login it opens frmMain.
If I hide frmLogin but still it is visible to the user.

If I hide the form, the form is still residing in the memory. Am I correct?
If so my application will be slower.

Regards
Partha


"Shiva" <sh******@online.excite.com> wrote in message
news:et**************@TK2MSFTNGP15.phx.gbl...
Hi,
Hide the login form (after successful logon) and show the main form using
ShowDialog() method (assuming logon form is the startup form).
Or, show the logon and main forms indepenantly (from Sub Main()). That is,
show the logon form using ShowDialog and based on the dialog result (eg:
DialogResult.OK for successful logon), close the logon form and show the
main form using Application.Run().

HTH.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password another form opens.

How do I close the login form?
Can any body help me!

Nov 21 '05 #4

P: n/a
Hello Cor,

My Login from is my Startup Object.
So the form is just having 2 textbox control for entering username & Password and Button control to validate the username & password stored in the database.

If the user name and password is correct, I am loding the main form.

I am pasting the code (excluding the database part) which I ahve written in the Button_Click block

Dim MainFrm As New frmMain
MainFrm.Show()

Dim LoginFrm As New frmLogin
LoginFrm.Close()
Could you help me.

As SHIVA has written to hide the form. I have got a issue that comes to my mind.

If I hide the form, the form is still residing in the memory. Am I correct?
If so my application will be slower.

Could you please give some input on this issue.

Regards & Thanks
Partha

"Cor Ligthert" <no************@planet.nl> wrote in message news:eC****************@TK2MSFTNGP11.phx.gbl...
Partha,

It is always difficult to see how people start there programs, so in
addition to Shiva, when I use a login form I start the login form in the
load event of my main form. (Did you already look at rollbased integrated
security by the way, than it can be that the login form is not needed).

However directly your question.

dim f as new loginform
f.showdialog
password = f.password
f.dispose.

I hope this helps?

Cor

Nov 21 '05 #5

P: n/a
Partha,

Using the login as startup object leads always to difficult situations.
When you use it as a dialog in your mainform it is very easy.

I hope you do not mind, that I not try to make a difficult approach to work?

When you set it in your load event the main form, than that mainform will
never been shown you do it as the code bellow because at that time when you
did not forced it, the main form is not yet showed, so you get exactly the
result you want.

dim f as new loginform
if f.showdialog <> dialogresult.ok then
me.close
else
if in pseudocode password = false then
me.close
else
'do your load event stuf
end if

I hope this gives you an idea

Cor
Nov 21 '05 #6

P: n/a
Yes, you are right - the login form will still be in memory after calling
Hide(). But if you made login form as the startup, I believe that is the
only option.

How about calling those two forms separately from Main()?

Eg:

Dim x As New frmLogin
If (x.ShowDialog() = DialogResult.OK) Then
Application.Run (New frmMain())
End If

Of course, the above code requires that you assign DialogResult.OK to
frmLogin's DialogResult property on successful login.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:#r**************@TK2MSFTNGP14.phx.gbl...
Hello Shiva,

Thank you for your answere

But my code is shown below, which is written in the button_Click procedure
block

Dim MainFrm As New frmMain

MainFrm.Show()

Dim LoginFrm As New frmLogin

LoginFrm.Hide()
frmLogin is the StartUp object, on successfully login it opens frmMain.
If I hide frmLogin but still it is visible to the user.

If I hide the form, the form is still residing in the memory. Am I correct?
If so my application will be slower.

Regards
Partha


"Shiva" <sh******@online.excite.com> wrote in message
news:et**************@TK2MSFTNGP15.phx.gbl...
Hi,
Hide the login form (after successful logon) and show the main form using
ShowDialog() method (assuming logon form is the startup form).
Or, show the logon and main forms indepenantly (from Sub Main()). That is,
show the logon form using ShowDialog and based on the dialog result (eg:
DialogResult.OK for successful logon), close the logon form and show the
main form using Application.Run().

HTH.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password another form opens.

How do I close the login form?
Can any body help me!


Nov 21 '05 #7

P: n/a
Shiva,

It is not happening the way I want.
I am attaching the code, if you could help

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
Dim LoginFrm As New frmLogin
LoginFrm.DialogResult = DialogResult.OK ' On vaild Username & Password
If LoginFrm.ShowDialog = DialogResult.OK Then
Application.Run(New frmMain)
LoginFrm.Hide()
End If
End Sub
What is happening is multiple instance of Login from is opened when it encounters "If LoginFrm.ShowDialog = DialogResult.OK Then"

Partha


"Shiva" <sh******@online.excite.com> wrote in message news:es****************@TK2MSFTNGP14.phx.gbl...
Yes, you are right - the login form will still be in memory after calling
Hide(). But if you made login form as the startup, I believe that is the
only option.

How about calling those two forms separately from Main()?

Eg:

Dim x As New frmLogin
If (x.ShowDialog() = DialogResult.OK) Then
Application.Run (New frmMain())
End If

Of course, the above code requires that you assign DialogResult.OK to
frmLogin's DialogResult property on successful login.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:#r**************@TK2MSFTNGP14.phx.gbl...
Hello Shiva,

Thank you for your answere

But my code is shown below, which is written in the button_Click procedure
block

Dim MainFrm As New frmMain

MainFrm.Show()

Dim LoginFrm As New frmLogin

LoginFrm.Hide()


frmLogin is the StartUp object, on successfully login it opens frmMain.
If I hide frmLogin but still it is visible to the user.

If I hide the form, the form is still residing in the memory. Am I correct?
If so my application will be slower.

Regards
Partha




"Shiva" <sh******@online.excite.com> wrote in message
news:et**************@TK2MSFTNGP15.phx.gbl...
Hi,
Hide the login form (after successful logon) and show the main form using
ShowDialog() method (assuming logon form is the startup form).
Or, show the logon and main forms indepenantly (from Sub Main()). That is,
show the logon form using ShowDialog and based on the dialog result (eg:
DialogResult.OK for successful logon), close the logon form and show the
main form using Application.Run().

HTH.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password

another
form opens.

How do I close the login form?
Can any body help me!



Nov 21 '05 #8

P: n/a
Hi,

Place LoginFrm.Hide() before Application.Run() because Run() will not return
until its associated forms is closed.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uA**************@TK2MSFTNGP15.phx.gbl...
Shiva,

It is not happening the way I want.
I am attaching the code, if you could help

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdGo.Click
Dim LoginFrm As New frmLogin
LoginFrm.DialogResult = DialogResult.OK ' On vaild Username &
Password
If LoginFrm.ShowDialog = DialogResult.OK Then
Application.Run(New frmMain)
LoginFrm.Hide()
End If
End Sub
What is happening is multiple instance of Login from is opened when it
encounters "If LoginFrm.ShowDialog = DialogResult.OK Then"

Partha


"Shiva" <sh******@online.excite.com> wrote in message
news:es****************@TK2MSFTNGP14.phx.gbl...
Yes, you are right - the login form will still be in memory after calling
Hide(). But if you made login form as the startup, I believe that is the
only option.

How about calling those two forms separately from Main()?

Eg:

Dim x As New frmLogin
If (x.ShowDialog() = DialogResult.OK) Then
Application.Run (New frmMain())
End If

Of course, the above code requires that you assign DialogResult.OK to
frmLogin's DialogResult property on successful login.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:#r**************@TK2MSFTNGP14.phx.gbl...
Hello Shiva,

Thank you for your answere

But my code is shown below, which is written in the button_Click procedure
block

Dim MainFrm As New frmMain

MainFrm.Show()

Dim LoginFrm As New frmLogin

LoginFrm.Hide()
frmLogin is the StartUp object, on successfully login it opens frmMain.
If I hide frmLogin but still it is visible to the user.

If I hide the form, the form is still residing in the memory. Am I correct? If so my application will be slower.

Regards
Partha


"Shiva" <sh******@online.excite.com> wrote in message
news:et**************@TK2MSFTNGP15.phx.gbl...
Hi,
Hide the login form (after successful logon) and show the main form using ShowDialog() method (assuming logon form is the startup form).
Or, show the logon and main forms indepenantly (from Sub Main()). That is, show the logon form using ShowDialog and based on the dialog result (eg:
DialogResult.OK for successful logon), close the logon form and show the
main form using Application.Run().

HTH.

"Partha Protim Roy" <pa****@capoint.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello,
My problem is:
I got a Login form, so once the user enter vaild Username & Password

another
form opens.

How do I close the login form?
Can any body help me!


Nov 21 '05 #9

P: n/a

"Partha Protim Roy" <pa****@capoint.com> wrote

It is not happening the way I want.
I am attaching the code, if you could help

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
Dim LoginFrm As New frmLogin
LoginFrm.DialogResult = DialogResult.OK ' On vaild Username & Password
If LoginFrm.ShowDialog = DialogResult.OK Then
Application.Run(New frmMain)
LoginFrm.Hide()
End If
End Sub
What form has the cmdGo button? It seems that would have been your
startup object....

Add a Module to your project, and in that module create a Sub Main.
Then set your project's start up object to Sub Main and use code like
this:

Sub Main()
Dim LogIn As LogIn
Dim OK As Boolean

LogIn = New LogIn
OK = (LogIn.ShowDialog = DialogResult.OK)
LogIn.Dispose()
LogIn = Nothing

If OK Then
Dim mf As MainForm
mf = New MainForm
Application.Run(mf)
mf.Dispose()
End If
End Sub
In your LogIn form, if the user passes your tests, then be sure to
call:

Me.DialogResult = DialogResult.OK

Or if not:

Me.DialogResult = DialogResult.Cancel

They both unload the form as part of the call....
HTH
LFS
Nov 21 '05 #10

P: n/a
Hello LFS,

Thank you for your help.

It is working fine.

Regards
Partha


"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:uN*************@TK2MSFTNGP12.phx.gbl...

"Partha Protim Roy" <pa****@capoint.com> wrote

It is not happening the way I want.
I am attaching the code, if you could help

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click Dim LoginFrm As New frmLogin
LoginFrm.DialogResult = DialogResult.OK ' On vaild Username & Password If LoginFrm.ShowDialog = DialogResult.OK Then
Application.Run(New frmMain)
LoginFrm.Hide()
End If
End Sub
What form has the cmdGo button? It seems that would have been your
startup object....

Add a Module to your project, and in that module create a Sub Main.
Then set your project's start up object to Sub Main and use code like
this:

Sub Main()
Dim LogIn As LogIn
Dim OK As Boolean

LogIn = New LogIn
OK = (LogIn.ShowDialog = DialogResult.OK)
LogIn.Dispose()
LogIn = Nothing

If OK Then
Dim mf As MainForm
mf = New MainForm
Application.Run(mf)
mf.Dispose()
End If
End Sub
In your LogIn form, if the user passes your tests, then be sure to
call:

Me.DialogResult = DialogResult.OK

Or if not:

Me.DialogResult = DialogResult.Cancel

They both unload the form as part of the call....
HTH
LFS

Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.