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 (Basic Syntax).
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.
- Sometimes functions will have more overloads than are available in Visual Basic.
For example, the CDate function supports the Visual Basic overload of creating a Date value from a String value, such as CDate ("Sept 18, 1999") but it also supports an overload of creating a Date value by supplying the year, month and day as Number arguments e.g. CDate (1999, 9, 18). The overloads are indicated in the Functions tree.
- Some functions that are supported by Basic syntax are not listed in the Basic syntax Functions tree. This is because they are equivalent to Basic syntax functions that are already listed in the tree.
For example, the Length function, which is the traditional Crystal syntax function for finding the length of a string, is not listed in the Basic Syntax functions tree because it works the same as the Len function.