Exitting application and signing out

  • Thread starter Thread starter Dino M. Buljubasic
  • Start date Start date
D

Dino M. Buljubasic

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
 
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/default.asp?url=/library/en-
us/cpref/html/frlrfsystemwindowsformsformclassclosingtopic.asp
 
Hello,

Dino M. Buljubasic said:
- 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
///
 
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
 
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
 

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

Back
Top