?
Solved

how to close VB application if the computer is inactive for a certain time?

Posted on 2003-03-18
9
Medium Priority
?
235 Views
Last Modified: 2010-04-07
i have made a VB .exe file for my users. but i want to close the application if a the user leaves it open and goes away.
it is not that urgent but it is certainly required by me.
0
Comment
Question by:bigbug7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 8164882
The straightforward answer is to have a timer procedure which ends the program after a defined period of inactivity. To detect the inactivity, reset the timer in the events of enabled forms and controls. You won't need to hook all events, probably MouseDown and KeyDown would be enough.

Something like this:

Public gEndTime As Date

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    gEndTime = DateAdd("h", 1, Now())'Period of one hour
End Sub


Private Sub Timer1_Timer()
   Timer1.Interval = 60000
   If Now() > gEndTime Then
       End
   End If
End Sub


 
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8166191
Insert one timer control and do as folowing

Dim tm As Date

Private Sub Form_Activate()
    tm = Now
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    tm = Now
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    tm = Now
End Sub

Private Sub Timer1_Timer()
    Debug.Print DateDiff("s", tm, Now)
    If (DateDiff("s", tm, Now) > 5) Then End
End Sub


0
 
LVL 5

Expert Comment

by:avya2k
ID: 8166200
set timer.interval=1000
'This will check for interaction with form for every second
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8166357
I have a sample I can send you if you give your e-mail address.
0
 

Expert Comment

by:CleanupPing
ID: 8532012
Hi bigbug7,
This old question (QID 20555746) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8957211
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9023670
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0
 

Author Comment

by:bigbug7
ID: 9097535
my email address is bigbug7@hotmail.com
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9098252
Now that the question is closed, you are back!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question