Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,573 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,913 people online right now. Registration is fast and FREE... Join Now!




How To Know User Log off in VB codes

 
Reply to this topicStart new topic

How To Know User Log off in VB codes

mafaisal
6 Apr, 2008 - 06:58 AM
Post #1

New D.I.C Head
*

Joined: 2 Mar, 2008
Posts: 7

Hello Experts

When the system user Log off the system , shutdown and so on How to know that in vbcode
Bcoz When user Log on i have vb application that automatically work, but when user logg off , shut down i have write code in application

My Application is small Program , Each users have 1 hour Per Day, After 1 hr Automatically Lock, then that user have no permission to login again.
But User Logoff beore 1 hour i have to insert his usage time in db .
How to know in codes the user manually logoff or shut down

Please Help me

Faisal

This post has been edited by mafaisal: 6 Apr, 2008 - 07:00 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: How To Know User Log Off In VB Codes
6 Apr, 2008 - 08:12 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,213



Thanked: 217 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well without seeing your code to know how you do your logoff procedure, ideally you would put an SQL statement in a function which would write the statement to database. Then you would call this function from a log off button or something like the Form_Terminate() event.

So I would start your search there at the form_terminate() event for your form and call a function which will insert the SQL into the database. This event fires whenever the form is closed (like pressing the X in the corner).

Now I say call a function to do this instead of writing the SQL in the event for an important reason. You want to be able to call this function from different locations. You want to call it from the menu when they select "exit" (if your application has a menu), you will want to call it from a log off button (if you have one), and you want to call it from the terminate event. It is better to have this code to record the time in one location so that in the future you can reuse this function or if you need to make changes to how this information is recorded to the database you change it only in one spot and it will change it for all three locations (menu, button, and the terminate event) simultaneously.

I hope that makes some sense to you and gives you an idea of how to go about doing this.

Enjoy!

"At DIC we be terminating code writing code ninjas... we also terminate others on a contract basis." decap.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:02AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month