Latest web development tutorials

VBScript CStr function

VBScript Reference Complete VBScript Reference

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

grammar

CStr(expression)

参数 描述
expression 必需。任何有效的表达式。

如果表达式是:

  • Boolean - CStr 函数将返回一个字符串,其中包含 true 或 false。
  • Date - CStr 函数将返回一个字符串,其中包含短日期格式的日期。
  • Null - 将发生 run-time 错误。
  • Empty - CStr 函数将返回一个空字符串("")。
  • Error - CStr 函数将返回一个字符串,其中包含单词 "Error" 和错误号码。
  • Other numeric - CStr 函数将返回一个字符串,其中包含数字。

Examples

Examples

<script type="text/vbscript">

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

</script>

Examples of the above output:

300000
10/5/2025

try it"

VBScript Reference Complete VBScript Reference