codecamp

VBScript CStr 函数

VBScript CStr 函数用于返回表达式,该表达式已被转换为 String 子类型的 Variant。


VBScript 参考手册完整的 VBScript 参考手册

CStr 函数把表达式转换为字符串(String)类型。

语法

CStr(expression)

参数

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

如果表达式是:

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

实例

实例

<script type="text/vbscript">

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

</script>

以上实例输出结果:

300000
10/5/2025

尝试一下 »

VBScript 参考手册完整的 VBScript 参考手册
VBScript CBool 函数
VBScript Asc 函数
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

VB 函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }