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 resultwill also be different.

Syntax

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

The result returned by CStr when the expression is different values:

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 followed by an error number.
Other Numbers String, containing this number.

Example

Example 1

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

De uitvoer is als volgt:

false

Example 1

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

De uitvoer is als volgt:

2001-1-1