473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Closing as Form

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
10 1528
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
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
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
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
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
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
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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.