ERR: Not a Numeric Expression

Last reviewed: November 28, 1995
Article ID: Q120536
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6x
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x

SYMPTOMS

You receive the error message "Not a numeric expression" after any of four types of @ ... GETs: buttons, radio buttons, popups, and list boxes.

CAUSE

The FoxPro for Windows "Developer's Guide" for versions 2.5x and 2.6x states on page B-26 that the error "Not a numeric expression" occurs when "An attempt was made to use the SUM command on a non-numeric field."

Another cause for this error message is using a variable that has not been initialized after being declared in a button, radio button, popup, or list box.

RESOLUTION

If a variable is declared, but not initialized, it contains the value of false (.F.). If you then use this variable as the variable for specific types of @ ... GET commands, you will see the "Not a numeric expression" error when you run the code.

The solution is to initialize the variable to a number, or to not declare the variable at all.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Place the following code in a program called TEST.PRG:

          CLEAR
          RELEASE ALL
          PUBLIC var1, var2, var3, var4
          DIMENSION myarray(4,1)
          myarray(1,1)="LIST1"
          myarray(2,1)="LIST2"
          myarray(3,1)="LIST3"
          myarray(4,1)="LIST4"
    

          DEFINE WINDOW main AT 0,0;
    
             SIZE 17.875,70.286 ;
             FONT "MS Sans Serif", 8 ;
             FLOAT ;
             NOCLOSE ;
             MINIMIZE ;
             SYSTEM
    
          ACTIVATE WINDOW main
    
          @ 4.500,3.429 GET var1 ;
             PICTURE "@*HN BUTTON1; BUTTON2" ;
             SIZE 1.625,11.875,0.500 ;
             DEFAULT 1
    
          @ 6.688,3.429 GET var2 ;
             PICTURE "@*RVN RADIO1; RADIO2" ;
             SIZE 1.063,7.750,0.250 ;
             DEFAULT 1
    
          @ 1.375,42.857 GET var3 ;
             PICTURE "@^ POPUP1; POPUP2" ;
             SIZE 1.500,15.125 ;
             DEFAULT 1
    
          @ 4.438,44.714 GET var4 ;
             PICTURE "@&N" ;
             FROM myarray ;
             SIZE 4.500,17.000 ;
             DEFAULT 1
    
          READ CYCLE
    
          RELEASE WINDOW main
    
    

  2. Run the program. The "Not a Numeric Expression" error will occur.

  3. Choose the Ignore button. The error will occur again for each @ ... GET defined in the program. If you keep choosing Ignore, the program will run through to the end.

Workaround

There are two ways to resolve this problem:

  • Remove the line "PUBLIC var1, var2, var3, var4" from the program, and run it again. It should work as expected.

    -or-

  • After declaring them, initialize VAR1, VAR2, VAR3, and VAR4 to 1. The program should no longer display the error.

REFERENCES

"Language Reference," version 2.5 (MS-DOS, Windows), pages L3-31 to L3-126


Additional reference words: FoxDos FoxWin VFoxWin 2.00 2.50 2.50a 2.50b
2.60 2.60a 3.00
listbox errmsg
KBCategory: kbprg kberrmsg
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 28, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.