Don't get lost: IMan Guides » IMan User Guide » References » VBScript Functions » Conversion Functions

Conversion Functions

Asc

Returns the NUMBER code that represents the specific character.

Syntax

  • Asc( string )

Arguments

  • string
    • The specified character to retrieve the NUMBER code for. If more than one character is entered, the function will return the value for the first character and ignore all of the characters after the first.

CBool

Converts a value to a boolean.

Syntax

  • CBool( expression )

Arguments

  • expression
    • Any valid expression. If expression is zero, False is returned; otherwise, True is returned. If expression can't be interpreted as a numeric value, a run-time error occurs.

CByte

converts a value to a byte. (ie: number between 0 and 255).

Use the CByte function to provide conversiMadCap:xrefns from any data type to a Byte subtype. For example, CByte forces byte arithmetic when currency, single-precision, double-precision, or integer arithmetic would normally occur.

The CByte function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

Syntax

  • CByte( expression )

Arguments

  • expression
    • Any valid expression. If expression lies outside the acceptable range for the byte subtype, an error occurs.

CCur

Use the CCur function to provide conversions from any data type to a Currency subtype. For example, CCur forces currency arithmetic when integer arithmetic would normally occur.

The CCur function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized, depending on the locale setting, as are different thousand separators.

Description

Returns an expression that has been converted to a Variant of subtype Currency.

Syntax

  • CCur( expression )

Arguments

  • expression
    • Any valid expression.

CDate

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.

Description

Returns an expression that has been converted to a Variant of subtype Date.

Syntax

  • CDate( date )

Arguments

  • date
    • Any valid date expression.

CDbl

Use the CDbl function to provide conversions from any data type to a Double subtype. For example, CDbl forces double-precision arithmetic when currency or integer arithmetic would normally occur.

The CDbl function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

Description

Returns an expression that has been converted to a Variant of subtype Double.

Syntax

  • CDbl( expression )

Arguments

  • expression
    • Any valid expression.

Chr

Description

Returns the character based on the number code.

Syntax

  • Chr( number_code )

Arguments

  • number_code
    • The NUMBER used to retrieve the character.

CInt

Use the CInt function to provide conversions from any other data type to an Integer subtype. For example, CInt forces integer arithmetic when currency, single-precision, or double-precision arithmetic would normally occur.

The CInt function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Integer subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Integer.

Syntax

  • CInt( expression )

Arguments

  • expression
    • Any valid expression.

CLng

Use the CLng function to provide conversions from any data type to a Long subtype. For example, CLng forces integer arithmetic when currency, single-precision, or double-precision arithmetic would normally occur.

The CLng function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Long subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Long.

Syntax

  • CLng( expression )

Arguments

  • expression
    • Any valid expression.

CSng

Use the CSng function to provide conversions from any data type to a Single subtype. For example, CSng forces single-precision arithmetic when currency or integer arithmetic would normally occur.

The CSng function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized depending on the locale setting, as are different thousand separators.

If expression lies outside the acceptable range for the Single subtype, an error occurs.

Description

Returns an expression that has been converted to a Variant of subtype Single.

Syntax

  • CSng( expression )

Arguments

  • expression
    • Any valid expression.

CStr

Use the CStr function to provide conversions from any data type to a String subtype. CStr forces the results to be expressed as a String.

The CStr function uses the locale setting of your system to determine how to perform conversions. Different decimal separators are properly recognized, depending on the locale setting.

The data in expression determines what is returned according to the following expressions:

Description

Returns an expression that has been converted to a Variant of subtype String.

  • Boolean
    • A String containing True or False.
  • Date
    • A String containing a date in the short-date format of your system.
  • Null
    • A run-time error.
  • Empty
    • A zero-length String ("").
  • Error
    • A String containing the word Error followed by the error number.
  • Other numeric
    • A String containing the number.

Syntax

  • CStr( expression )

Arguments

  • expression
    • Any valid expression.

Hex

Description

Returns a string representing the hexadecimal value of a number.

Syntax

  • Hex(number)

Arguments

  • number
    • Any valid expression. If number is not a whole number, it is rounded to the nearest whole number before the number is evaluated.

IsNumeric

Description

Returns a Boolean value indicating whether an expression can be evaluated as a number.

Syntax

  • IsNumeric(expression)

Arguments

  • expression
    • Any valid expression.

Oct

Description

Returns a string representing the octal value of a number.

Syntax

  • Oct(number)

Arguments

  • number
    • Any valid expression. If number is not already a whole number, it is rounded to the nearest whole number before being evaluated.