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

Exitting application and signing out

P: n/a
I know this sounds ridiculous but I am having problems when exiting/sighing
out of my application.

I have two forms, Login and Main. On Main form, I have two buttons, Sign
Out and Exit. These two buttons and the close button (X) should ask user to
confirm exiting or signing out, then if Yes, they should write log file and
then do:
- When I click exit, I should close both, main and login form.
- when I click Sign out, I should close only main and show login form.

That is simple, but the problem starts when I want my X (close button on
main form, upper right corner) to behave the same way as my Exit button.

Any help will be appreciated

--
Dino Buljubasic
Software Developer
http://rivusglobal.com
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in
news:%q*****************@news1.telusplanet.net:

That is simple, but the problem starts when I want my X (close button
on main form, upper right corner) to behave the same way as my Exit
button.

I think this should work. Basically you handle the Form.Closing event:

Public Sub test(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

'Execute a Sub
MsgBox("The Form is Closing!")

'You can stop Form.Close from closing by doing this
e.Cancel = True
End Sub

There's some stuff in the docs about not putting validation code in the
closing method... I haven't read through it carefully so I don't know
what problems this may cause.

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfsystemwindowsformsformclassclosingtopic.asp

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2

P: n/a
Cor
Hi Lucas,
Public Sub test(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

'Execute a Sub
MsgBox("The Form is Closing!")

'You can stop Form.Close from closing by doing this
e.Cancel = True
End Sub

Looks like the good old days, closing programs with ctrl alt del
:-)

(I know you can put an if before it in a real program).
Cor

Nov 20 '05 #3

P: n/a
Hello,

"Dino M. Buljubasic" <di*************@rivusglobal.com> schrieb:
- When I click exit, I should close both, main and
login form.
- when I click Sign out, I should close only main and
show login form.

That is simple, but the problem starts when I want my
X (close button on main form, upper right corner) to
behave the same way as my Exit button.


\\\
Private Sub Form1_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs _
) Handles MyBase.Closing
If ... Then
e.Cancel = True ' Cancel closing process.
End If
End Sub
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Is there a way for me inside the form.closing event to detect which button
is calling the form.close?

That way, I could distinguish btw my Sign Out, Exit and X buttons

Thank you for your help

--
Dino Buljubasic
Software Developer
http://rivusglobal.com

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:Or**************@TK2MSFTNGP10.phx.gbl...
Hello,

"Dino M. Buljubasic" <di*************@rivusglobal.com> schrieb:
- When I click exit, I should close both, main and
login form.
- when I click Sign out, I should close only main and
show login form.

That is simple, but the problem starts when I want my
X (close button on main form, upper right corner) to
behave the same way as my Exit button.


\\\
Private Sub Form1_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs _
) Handles MyBase.Closing
If ... Then
e.Cancel = True ' Cancel closing process.
End If
End Sub
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.