?? 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 + -