Variable Declaration
Collapse the table of content
Expand the table of content

Variable Declaration (Visual FoxPro)

You can compare how variable declaration differs between Visual FoxPro and other programming languages. In Visual FoxPro, you do not assign a data type to a variable. However, it is recommended that you name your variable with a prefix suggesting the data type you plan to use it with. Other languages require that you assign a data type to a variable when you declare it. For more information, see Variable Naming Conventions.


When you store a value to a variable and the variable does not exist, Visual FoxPro implicitly declares it with PRIVATE scope. Other languages that require explicit declaration of variables return an error. To create variables in Visual FoxPro with PUBLIC or LOCAL scope, you must explicitly declare them with the PUBLIC or LOCAL command. For more information, see PUBLIC Command and LOCAL Command.

Visual FoxPro BASIC

Variables are implicitly declared with no data typing.

Variables can be implicitly declared, and the variable name dictates data type.

Pascal C/C++

Variables must be explicitly declared and assigned a data type.

Variables must be explicitly declared and assigned a data type.

Community Additions

© 2016 Microsoft