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

David McAmis

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

Functions

Crystal Reports includes a number of pre-built functions that are available for use within a formula. The majority of these functions are the same in both Basic and Crystal Syntax, with the exception of the functions below.

Note

Where there is more than one equivalent function, they are all listed.

Mathemetical

Basic

Crystal

Fix(n) Truncate(n)

Fix(n, #places) Truncate(n, #places) Where n is a number-type field, both Fix() and Truncate() will truncate a number to a specified number of decimal places.

For example Fix({field}, 2) would trim the field to two decimal places.

String Functions

Basic

Crystal

Notes

Len (string) Length(string) Returns the length of a string

LTrim (string) TrimLeft (string) Trims all spaces from the left-hand side of a string

RTrim (string) TrimRight (string) Trims all spaces from the right-hand side of a string

UCase (string) Uppercase (string) Converts a string to all uppercase characters

LCase (string) Lowercase (string) Converts a string to all lowercase characters

IsNumeric (string) n/aBoolean - determines whether a string is numeric or not

CStr(field), ToText (field) CStr(field), ToText (field) Converts different types of fields to string

Date/Time Functions

Basic

Crystal

Notes

CDate, DataValue CDate, DateValue Date

CTime, TimeValue Ctime, TimeValue, Time Time

CDateTime, DateTimeValue DateTime, CDateTime, DateTimeValue Date-Time

WeekDay DayofWeek Returns the day of week

Arrays

Basic

Crystal

Notes

Array (x, ...) MakeArray (x, ...) For creating arrays of different types within your formula

Operators

In addition to different types of functions, Basic and Crystal occasionally utilize different operators:

Arithmetic

Basic

Crystal

n/ax%y This is the percent operator, and it calculates the percent that X is of Y.

Conversion

Basic

Crystal

n/aToCurrency This operator is for converting a field to a currency format with two decimal places.

String

Basic

Crystal

Notes

& &, + Similar in function, the ampersand can also be used to concatenate different types of fields, while the plus operator only works with string fields

(x(y)) x[y] For referencing the subscript of arrays and strings, Basic uses parenthesis, while Crystal syntax uses brackets (for example {stringfield}[3] would return the character in the third position of the string)