TIME$ Used Twice in IF Statement May Differ; TIME$ 24: 00 Issue (44305)
The information in this article applies to:
- Microsoft QuickBASIC 4.0
- Microsoft QuickBASIC 4.0b
- Microsoft QuickBASIC 4.5
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
- Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
- Microsoft Basic Professional Development System for MS-DOS 7.0
- Microsoft Basic Professional Development System for MS-DOS 7.1
This article was previously published under Q44305 SUMMARY
If you test the TIME$ function twice in one IF statement, the returned
time may change between invocations and give you a conditional result
that you did not expect. In the example below, the symptoms occur
intermittently only during the tenth of a second at midnight
(24:00:00). To correct this programming mistake, you should assign the
value returned by TIME$ to a temporary string variable, which can then
be reliably tested multiple times in the IF statement.
This information applies to Microsoft QuickBasic versions 4.0, 4.0b,
and 4.50 for MS-DOS; to Microsoft Basic Compiler versions 6.0 and 6.0b
for MS-DOS; and to Microsoft Basic Professional Development System
(PDS) versions 7.0 and 7.1 for MS-DOS. (Programs compiled with BC.EXE
may not be as sensitive to this timing issue as the QB.EXE or QBX.EXE
environment.)
Modification Type: | Minor | Last Reviewed: | 8/16/2005 |
---|
Keywords: | KB44305 |
---|
|