Microsoft KB Archive/147277

= FIX: Using an Array Element as the Counter in a For Loop Fails =

Article ID: 147277

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition

-



This article was previously published under Q147277



SYMPTOMS
In FoxPro and Visual FoxPro, attempting to use an array element as the counter variable in a FOR...ENDFOR command results in the error, "Not a numeric expression." If the array hasn't been declared, you may receive the error, "Variable not found."



WORKAROUND
Use a memory variable instead of an array element.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0 for Windows.



MORE INFORMATION
According to the FoxPro and Visual FoxPro language reference, you should be able to use an array element as the counter variable in a FOR...ENDFOR Command.

Steps to Reproduce Problem
Type the following code into a program file: DIMENSION aTest[1]

FOR aTest[1]=1 TO 10 WAIT WINDOW "This is a test" ENDFOR When you run this program you will receive the error, "Not a numeric expression." If you replace aTest[1] with nMyVar in the FOR statement it will work correctly.

Keywords: kbbug KB147277

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.