Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Closing a form after a period of inactivity
Message
From
23/03/2004 21:05:43
 
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00886289
Message ID:
00889090
Views:
23
'Good day,
'
'I have a Visual Basic form that shows customer information and the
'users that enter the data sometimes leave the form open with all
'the sensitive information displayed while they do something else.
'I would like to know if there is a way to set a timeout that when
'there is no activity (mouse or keyboard) for a period of time the
'form would close. Or perhaps the entire project would close if
'there is no activity. Is there a way to do this? If you can give
'an example of code it would really help!
'Thank you for your time and help!

'------------------------------------------------------------------------------------
Option Explicit

'As I told you, use the Timer control to close the Aplication like this
'assign the amount of time to the timer with the interval property
'Once the amount of time assigned has been transcurred, use this code to close the
'form

Private Sub Timer1_Timer()
Unload Me
End Sub

'if you want to close the application, use End instead of Unload Me


'this should work, but what about stoping the timer control when the user
'start using the form again before the timer finishes the amount of time assigned?
' I am using the mouse move event to to re-assign the value of the timer interval again like this

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Timer1
.Enabled = False
.Interval = 10000 ' the amount assigned for u goes here!
.Enabled = True
End With
End Sub

'what about if the user only uses the Keyboard? huum... let's do this!

Private Sub Form_KeyPress(KeyAscii As Integer)
With Timer1
.Enabled = False
.Interval = 10000 ' the amount assigned for u goes here!
.Enabled = True
End With
End Sub

' I hope this works for u, I haven't been programming for a while now, since I've been
'working with Video Edition, but this is something I made up for u, cus all the members
'of Universal Thread are brothers, and we have to help each others man, don't cha think?
'Take Care, and keep programming, there's nothing compare to that sensation!
cheers!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform