Share via


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.

Note

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.

See Also

Reference

Variables (Visual FoxPro)

Access to Variables

Visual FoxPro and Other Programming Languages