Professional.Crystal.Reports.for.Visual.Studio..NET [Electronic resources]

David McAmis

نسخه متنی -صفحه : 115/ 87
نمايش فراداده

Variable Declarations

Before we can use a variable in a formula, it has to be declared. Basic and Crystal Syntax both have different ways of declaring variables, based on the type and scope of the variable. The most common variable declarations are included below:

Basic

Crystal

Dim x n/a

Dim x () n/a

Dim x As Boolean Local BooleanVar x

Dim x As Number Local NumberVar x

Dim x As Currency Local CurrencyVar x

Dim x As Date Local DateVar x

Dim x As Time Local TimeVar x

Dim x As DateTime Local DateTimeVar x

Dim x As String Local StringVar x

Dim x As Number Range Local NumberVar range x

Dim x As Currency Range Local CurrencyVar range x

Dim x As Date Range Local DateVar range x

Dim x As Time Range Local TimeVar range x

Dim x As DateTime Range Local DateTimeVar range x

Dim x As String Range Local StringVar range x

Dim x () As Boolean Local BooleanVar array x

Dim x () As Number Local NumberVar array x

Dim x () As Currency Local CurrencyVar array x

Dim x () As Date Local DateVar array x

Dim x () As Time Local TimeVar array x

Dim x () As DateTime Local DateTimeVar array x

Dim x () As String Local StringVar array x

Dim x () As Number Range Local NumberVar range array x

Dim x () As Currency Range Local CurrencyVar range array x

Dim x () As Date Range Local DateVar range array x

Dim x () As Time Range Local TimeVar range array x

Dim x () As DateTime Range Local DateTimeVar range array x

Dim x () As String Range Local StringVar range array x To select a scope for variables created in Basic syntax, you can use the following scope attributes in place of the Dim statement:

Local - The variable is specific and can only be used in the formula in which it is defined.

Global - The variable is available to formulas throughout the entire current report.

Shared - The variable can be shared with a subreport as well as the entire current report.

Note

Dim is equivalent to using "Local".