PRB: Run-Time Overflow Error w/Byte-Type Counter in For LoopLast reviewed: September 29, 1997Article ID: Q129709 |
The information in this article applies to:
SYMPTOMSUsing a byte variable as a counter in a For loop with a negative Step value causes an Overflow error at run-time.
CAUSEIn a For loop in Visual Basic for Windows, the Start, Limit and Step values are all coerced to the type of the For loop counter. Since the byte data type cannot be negative, it cannot have a negative step value.
RESOLUTIONThis is a limitation of the implementation of the byte datatype and For loop. The solution is to never use byte type variables in For loops where the step is negative or a variable (since the variable may contain a negative number at some future time.)
STATUSThis behavior is by design.
MORE INFORMATIONSteps to Reproduce Behavior in Visual Basic Version 4.0
|
Additional query words: increment decrement counter
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |