VBScript CStrFunction


VBScript 参考手册Complete VBScript Reference

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

Syntax

CStr(expression)

Parameters Description
expression Required. Any valid expression.

If the expression is:

  • Boolean - The CStr function returns a string containing true or false.
  • Date - The CStr function returns a string containing a date in short date format.
  • Null - A run-time error will occur.
  • Empty - The CStr function returns an empty string ("").
  • Error - The CStr function returns a string containing the word "Error" and the error number.
  • Other numeric - The CStr function returns a string containing the number.

Example

Example

<script type="text/vbscript">

document.write(CStr("300000") & "<br />")
document.write(CStr(#10-05-25#) & "<br />")

</script>

The output of the above example is:

300000
10/5/2025

Try it yourself »

VBScript 参考手册Complete VBScript Reference Other Extensions