Type Conversion


These functions allow you to convert from one data type to another.

Table C-10: Type conversion functions

Function

Description

Arguments

CBool (number)

Changes a number or currency value to a Boolean data type.

number is a Number or a Currency type value.

CCur (number)

CCur (string)

Changes a number, currency, or string value to a Currency data type.

number is a Number or a Currency type value.

string is a text string that holds numeric text.

CDbl (number)

CDbl (string)

CDbl (Boolean)

Converts a Number, Currency, text string, or Boolean value to a Number.

CDbl and ToNumber are equivalent functions.

number is a Number or a Currency type value.

string is a text string that holds numeric text.

Boolean is a Boolean value that you want to treat as a number.

CStr (x, y, z, w, q)

Converts Numbers, Currency, Date, Time, and DateTime values to text strings.

Boolean Values:

x is a Boolean value that is converted to a String, either "True" or "False."

Number and Currency Values:

x is a Number or Currency value to be converted into a text string; it can be a whole or fractional value.

y is a whole number indicating the number of decimal places to carry the value in x to. (This argument is optional.)

z is a single-character text string indicating the character to be used to separate thousands in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

w is a single-character text string indicating the character to be used as a decimal separator in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

Number and Currency Values (formatting):

x is a Number or Currency value to be converted into a text string; it can be a whole or fractional value.

y is a text string used to indicate the format for displaying the value in x.

z is a whole number indicating the number of decimal places to carry the value in x to. (This argument is optional.)

w is a single character text string indicating the character to be used to separate thousands in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

q is a single-character text string indicating the character to be used as a decimal separator in x. The default is the character specified in your International or Regional settings control panel. (This argument is optional.)

DateTime Values:

x is a DateTime value to be converted into a text string.

y is a text string of characters that indicate how the resulting text string will be formatted.

z is a text string to be used as a label for A.M. (morning) hours. (This argument is optional.)

w is a text string to be used as a label for P.M. (evening) hours. (This argument is optional.)

CDate (string)

CDate (number)

CDate (dateTime)

CDate (YYYY, MM, DD)

Returns a Date value.

The CDate, Date, and DateValue functions are equivalent. However, Date can only be used in Crystal syntax since it is a type name in Basic syntax.

string is a text value that represents the date.

number represents the number of days starting from December 30, 1899.

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

CTime (number)

CTime (string)

CTime (dateTime)

CTime (HH, MM, SS)

Returns a Time value.

The CTime, Time, and TimeValue functions are equivalent. However, Time can only be used in Crystal syntax since it is a type name in Basic syntax.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.

CDateTime (date)

CDateTime (number)

CDateTime (string)

CDateTime (dateTime)

CDateTime (YYYY, MM, DD)

CDateTime (YYYY, MM, DD, HH, MM, SS)

Returns a DateTime value.

The CDateTime, DateTime, and DateTimeValue functions are equivalent. However, DateTime can only be used in Crystal syntax since it is a type name in Basic syntax.

date is a Date value.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.




Mastering Business Analysis with Crystal Reports 9
Mastering Business Analysis with Crystal Reports 9 (Wordware Applications Library)
ISBN: 1556222939
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Chris Tull

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net