[]
To increase compatibility with code written in Visual Basic and Microsoft Access (VBA), C1FlexReport exposes two functions that are not available in VBScript: Iif and Format.
Iif evaluates a Boolean expression and returns one of two values depending on the result. For example:
Iif(SalesAmount > 1000, "Yes", "No")
Format converts a value into a string formatted according to instructions contained in a format expression. The value may be a number, Boolean, date, or string. The format is a string built using syntax similar to the format string used in Visual Basic or VBA.
The following table describes the syntax used for the format string:
Value Type | Format String | Description |
---|---|---|
Number | Percent, % | Formats a number as a percentage, with zero or two decimal places. For example: |
#,###.##0 | Formats a number using a mask. The following symbols are recognized: # digit placeholder 0 digit placeholder, force display , use thousand separators ( enclose negative values in parenthesis % format as percentage For example: | |
Currency | Currency, $ | Formats a number as a currency value. Displays number with thousand separator, if appropriate; displays two digits to the right of the decimal separator. For example: |
Boolean | Yes/No | Returns "Yes" or "No". |
Date | Long Date |
|
Short Date |
| |
Medium Date |
| |
q,m,d,w,yyyy | Returns a date part (quarter, month, day of the month, week of the year, year). For example: | |
String | @@-@@/@@ | Formats a string using a mask. The "@" character is a placeholder for a single character (or for the whole value string if there is a single "@"). Other characters are intercodeted as literals. For example: |
@;Missing | Uses the format string on the left of the semi-colon if the value is not null or an empty string, otherwise returns the part on the right of the semi-colon. For example: |
Note that VBScript has its own built-in formatting functions (FormatNumber, FormatCurrency, FormatPercent, FormatDateTime, and so on). You may use them instead of the VBA-style Format function described here.