VBScript CStr Function

Definition and Usage

The CStr function can convert an expression to a string (String) type.

Note:If the type of the expression is different, then CStr Output resultswill also be different.

Syntax

CStr(expression)
Parameter Description
expression Required. Any valid expression.

When the expression is different values, the result returned by CStr:

Possible values of the expression The corresponding return result of CStr
Boolean String, containing True or False.
Date String, containing the system's short date format date.
Null A run-time error will occur.
Empty Zero-length string ("").
Error String, containing the word Error following the error number.
Other numerical values String, containing this number.

Example

Example 1

dim a
a=false
document.write(CStr(a))

The outputs are:

false

Example 1

dim a
a=#01/01/01#
document.write(CStr(a))

The outputs are:

2001-1-1