Export (0) Print
Expand All

Variables (Crystal Syntax)

Visual Studio 2005

A variable represents a specific data item, or value, and acts as a placeholder for that value. When a formula encounters a variable, the formula searches for the value of the variable and uses it in the formula. Unlike a constant value, which is fixed and unchanging, a variable can be repeatedly assigned different values. You assign a value to a variable and the variable maintains the value until you later assign a new value. Because of this flexibility, it is necessary for you to declare variables before you use them so that Crystal Reports is aware of them and understands how you intend to use them.

Example

If you wanted to report on customers by area code, you could create a variable that extracts the area code from a customer fax number. The following is an example of a variable called areaCode:

Local StringVar areaCode;
areaCode := {Customer.Fax} [1 To 3];

The first line of the variable example is the variable declaration; it gives the variable a name and type. The database field {Customer.Fax} is a String field and [1 To 3] extracts the first three characters from its current value. The variable areaCode is then assigned this value.

See Also

Variable Declarations (Crystal Syntax) | Variable Scope (Crystal Syntax) | Declaring Array Variables (Crystal Syntax) | Default Values for Simple Data Types (Crystal Syntax)

Show:
© 2014 Microsoft