Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Math with time
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00327347
Message ID:
00328347
Views:
21
>>Anyone doing any math with time?
>>
>>Say I wanted to time out a form. I call my foo sub and want to time this form out in approx (dynamic) minutes. Say I call the (VB time function) and try to say MyTimeOut time = (VB time function) + (dynamic) minutes. Then in the form I can ease the system strain by setting my timer to check the actual time every 65 seconds for (VB Time function) to => MyTimeOut vice an incrementer variable.
>>
>>I have tried a number of methods and it apears that i have missed the boat. I Realize that this is a little academic :) but does any one have any ideas.
>
>I already used this. Maybe it can help!
>
>On a form, add a Timer control (named tmrIdleDetect), set its Interval property to what ever you want greater than 0 (60000 is a good choice) and paste this code:
>
>
>Private Sub tmrIdleDetect_Timer()
>' IDLEMINUTES determines how much idle time to wait for before
>' running the IdleTimeDetected subroutine.
>Const IDLEMINUTES = 10
>Static strPrevControlName As String
>Static strPrevFormName As String
>Static sngExpiredTime As Single
>Dim strActiveFormName As String
>Dim strActiveControlName As String
>Dim sngExpiredMinutes As Single
>
>    'Only effective between 10PM and 6AM
>    If Not (Now > CDate(DateSerial(Year(Date), Month(Date), Day(Date)) & " " & TimeSerial(22, 0, 0)) And _
>            Now < CDate(DateSerial(Year(Date), Month(Date), Day(Date) + 1) & " " & TimeSerial(6, 0, 0))) _
>    Then
>        Exit Sub
>    End If
>
>    On Error Resume Next
>
>    ' Get the active form and control name.
>    strActiveFormName = Screen.ActiveForm.Name
>    If Err.Number Then
>        strActiveFormName = "No Active Form"
>        Err.Clear
>    End If
>    strActiveControlName = Screen.ActiveControl.Name
>    If Err.Number Then
>        strActiveControlName = "No Active Control"
>        Err.Clear
>    End If
>
>    ' Record the current active names and reset ExpiredTime if:
>    '    1. They have not been recorded yet (code is running
>    '       for the first time).
>    '    2. The previous names are different than the current ones
>    '       (the user has done something different during the timer
>    '        interval).
>    If (strPrevControlName = "") Or _
>       (strPrevFormName = "") Or _
>       (strActiveFormName <> strPrevFormName) Or _
>       (strActiveControlName <> strPrevControlName) _
>    Then
>        strPrevControlName = strActiveControlName
>        strPrevFormName = strActiveFormName
>        sngExpiredTime = 0
>    Else
>    ' ...otherwise the user was idle during the time interval, so
>    ' increment the total expired time.
>        sngExpiredTime = sngExpiredTime + tmrIdleDetect.Interval
>    End If
>
>    ' Does the total expired time exceed the IDLEMINUTES?
>    sngExpiredMinutes = (sngExpiredTime / 1000) / 60
>    If sngExpiredMinutes >= IDLEMINUTES Then End
>End Sub
>
>
Cool Eric, my thanks. I will be working this in very soon.
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Reply
Map
View

Click here to load this message in the networking platform