📄 5-6.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>格式转换函数</title>
</head>
<body>
<h1 align="center">格式转换函数</h1>
<script language="VBScript">
<!--
n=5
//字符串默认转化,不能直接用数值与字符串进行连接,但可以用数值变量进行连接
document.write """字符串:"" &n&"":""&date()&"":""&true = "&"字符串:" &n&":"&date()&":"&true&"<br>"
//字符串强制转化
document.write """字符串:"" &CStr(5)&"":""&CStr(date())&"":""&CStr(true) = "&"字符串:" &CStr(5)&":"&CStr(date())&":"&CStr(true)&"<br>"
document.write "<br>"
//字符串转化为日期型数据
document.write "CDate(""2008-1-1"") = "&CDate("2008-1-1")&"<br>"
//数值型转化为日期型数据,数值为1899-12-31开始的天数
document.write "CDate(39448) = "&CDate(39448)&"<br>"
document.write "<br>"
//cint按照四舍五入的原则转化成整数类型
document.write "cint(""2.6"") = "&cint("2.6")&"<br>"
//cint对0.5四舍五入时,总是把将其四舍五入到最近的一个偶数
document.write "cint(2.5) = "&cint(2.5)&"<br>"
document.write "cint(3.5) = "&cint(3.5)&"<br>"
//布尔型转为数值型
document.write "cint(false) = "&cint(false)&"<br>"
document.write "<br>"
//Clng可以处理长整型数据,其四舍五入方式同Cint
document.write "CLng(""123456789.6"") = "&CLng("123456789.6")&"<br>"
//转化成单精度浮点数,其四舍五入方式同Cint
document.write "CSng(""123.456789"") = "&CSng("123.456789")&"<br>"
document.write "CSng(""123.456789"") = "&CSng("123456.789")&"<br>"
//转化成双精度浮点数,其四舍五入方式同Cint
document.write "CDbl(""123.456789123456789"") = "&CDbl("123.456789123456789")&"<br>"
document.write "<br>"
//字符串转化为布尔型
document.write "CBool(""true"") = "&CBool("true")&"<br>"
//数值转化为布尔型
document.write "CBool(0) = "&CBool(0)&"<br>"
document.write "<br>"
//数值型数据格式处理
document.write "FormatNumber(12345) = "&FormatNumber(12345)&"<br>"
document.write "FormatNumber(12345.678,2) = "&FormatNumber(12345.678,2)&"<br>"
document.write "FormatNumber(12345.678,2,,,0) = "&FormatNumber(12345.678,2,,,0)&"<br>"
document.write "<br>"
//货币型数据格式处理
document.write "FormatCurrency(12345) = "&FormatCurrency(12345)&"<br>"
document.write "FormatCurrency(12345.678,3) = "&FormatCurrency(12345.678,3)&"<br>"
document.write "FormatCurrency(12345.678,3,,,0) = "&FormatCurrency(12345.678,3,,,0)&"<br>"
document.write "<br>"
//日期型数据格式处理
document.write "FormatDateTime(now(),1)= "&FormatDateTime(now(),1)&"<br>"
document.write "FormatDateTime(now(),2)= "&FormatDateTime(now(),2)&"<br>"
document.write "FormatDateTime(now(),3)= "&FormatDateTime(now(),3)&"<br>"
document.write "<br>"
//数据百分比格式处理
//10 是 100 的百分之几
document.write "FormatPercent(10/200) = "&FormatPercent(10/100)&"<br>"
//5是 145 的百分之几,取一位小数
document.write "FormatPercent(5/145,1) = "&FormatPercent(5/145,1)&"<br>"
-->
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -