Crystal Reports  

Functions Overview (Basic Syntax)

When using a function in a formula, type the name of the function and supply the arguments required. For example, the Len function requires a String argument and computes the length of the string.

Dim x As String
x = "hello"
formula = Len (x) 'The formula returns the Number 5

Supplying arguments of the incorrect type required by the function produces an error. For example, calling Len (3) would produce an error since Len does not accept a Number argument.

Functions sometimes can accept different numbers of arguments or types of arguments. For example, the CDate function could accept a single String argument to form a Date value or 3 Number values holding the year, month and day respectively and form a Date value from them. See Date, Time, and DateTime.

Example with the Mid function

Dim x as String
x = "hello"
'Start at position 2, go to the end of the string
formula = Mid (x, 2) 'formula is now "ello"
'Start at position 2, extract 1 character
formula = Mid (x, 2, 1) 'formula is now "e"

The classes of functions are: Math, Summary, Financial, String, Date/Time, Date Range, Array, Type Conversion, Programming Shortcuts, Evaluation Time, Print State, Document Properties and Additional Functions. There are also some functions specific to conditional formatting formulas.

Functions Similar to Visual Basic Functions

The Math, Financial, String, Date/Time, Type Conversion and Programming Shortcuts groups consist mainly of functions that are familiar to Visual Basic users. Most of the functions are intended to work in the same way as the Visual Basic function of the same name.

See Also

Performing Report Calculations