Home > Software engineering >  Novice Europe code (countdown software source code)
Novice Europe code (countdown software source code)

Time:10-06

I am novice, downloaded from the Internet a countdown software VB source code, but found a timeout after modified computing time, below is the code, and guidance,
 Private Sub Timer1_Timer () 'C + Z/X 
The Static As Long I
If I=1200 Then I=0
If I Mod 10=0 Then
Seconds=CInt (Seconds) + 1

If Seconds="60" Then
Seconds="00"
Minutes=CInt (Minutes) + 1
The Debug. Print you
End the If
If you can="60" Then
Minutes="00"
Hours=CInt (Hours) + 1
End the If

MyTime=Format (Hours, "00") & amp; ":" & amp; Format (Minutes, "00") & amp; ":" & amp; The Format (Seconds, "00")
FrmStr="timeout:" & amp; MyTime
Call FrmTimer
End the If
I=I + 1
If Hotkey (vbKeyControl vbKeyZ)=True Then Form1. Show
If Hotkey (vbKeyControl vbKeyX)=True Then frmLCD. Show

CodePudding user response:

ask for advice

CodePudding user response:

Time is short, should not be sent a lot of,

CodePudding user response:

To precise timing, can use the Timer () function, obtain from midnight until now, after the number of seconds, two decimal places,
Calculate the current in the Timer and start the Timer () difference, is through the number of seconds,

CodePudding user response:

When the source of normal countdown is no problem, is to go after the timeout time is slow

CodePudding user response:

I think is a problem of accumulated error ",
System does not guarantee the Timer control Timer () event triggering precision,
Your "time" in the long run, is likely to produce error,

I think, or according to the system time to calculate, the result is more reliable,
At the beginning of the "plan", the system time record at that time, the starting point is: time,
Then, update the display interface to your application, according to the current time and start time difference,
Calculate the corresponding project duration in the program screen,
This way, only in the case of processed and across day midnight, logically complex,
If it is "the time" in the day, is also very simple,
This way, will not appear the original poster said of that kind of phenomenon,

CodePudding user response:

TimeGetTime
The timeGetTime function retrieves The system time, in milliseconds. The system time is The time elapsed since Windows was started.

DWORD timeGetTime (VOID);
The Parameters
This function does not take parameters.

The Return Values
Returns the system time, in milliseconds.

Few
The only difference between this function and The timeGetSystemTime function is that timeGetSystemTime USES The MMTIME structure to return The system time. The timeGetTime function has less overhead than timeGetSystemTime.

Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2 ^ 32 milliseconds, which is about 49.71 days. This can cause the problems in code that directly USES the timeGetTime return value in computations, particularly where the value is 2 control code execution. You should always use the difference between two timeGetTime return values in computations.

Windows NT: The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime. If you do so, the minimum difference between successive values returned by timeGetTime can be as large as the minimum period value set using timeBeginPeriod and timeEndPeriod. Use the QueryPerformanceCounter and QueryPerformanceFrequency functions to measure short time intervals at a high resolution,

Windows 95: The default precision of The timeGetTime function is 1 millisecond. In other words, The timeGetTime function can return successive values that differ by just 1 millisecond. This is true no matter what calls have had been made to The timeBeginPeriod and timeEndPeriod functions provides.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in mmsystem. H.
The Import Library: Use winmm. Lib.

See Also
Multimedia Timers Overview, Multimedia Timer Functions provides timeGetSystemTime, MMTIME, timeGetTime, timeBeginPeriod and timeEndPeriod, QueryPerformanceCounter, QueryPerformanceFrequency


CodePudding user response:

reference 4 floor liouxin888 response:
normal countdown when the source is no problem, is to go after the timeout time slowed

VB timer control, as well as other controls have a free time response, the premise of
If the code into the long time operation state, there would be no response interface;
If the same FrmTimer the execution time of the former is greater than the time interval, so regular news cast a few very normal,
So don't put the time message for real-time timing, want to use the Timer (), Now () function take time difference,

CodePudding user response:

Feel the building Lord give only a section of the middle, middle code, what to say,

CodePudding user response:

I'm upstairs said all good ah, can be considered

CodePudding user response:

Alternatively, read the system time lag calculated timeout
  • Related