2004/06/15 | 我的asp学习笔记-Some Other Functions (VBScript)
类别(asp) | 评论(0) | 阅读(101) | 发表于 10:42
1.Uppercase or lowercase a string(大小写)
<html>
<body>

<%
name = "Bill Gates"
response.write(ucase(name))
response.write("
")
response.write(lcase(name))
%>

</body>
</html>
2.Trim a string(去掉空格)
<html>
<body>

<%
name = " W3Schools "
response.write("visit" & name & "now<br />")
response.write("visit" & trim(name) & "now<br />")
response.write("visit" & ltrim(name) & "now<br />")
response.write("visit" & rtrim(name) & "now")
%>

</body>
</html>

3.How to reverse a string(反向输出)
<html>
<body>

<%
sometext = "Hello Everyone!"
response.write(strReverse(sometext))
%>

</body>
</html>

4.How to round a number?(四舍五入)
<html>
<body>

<%
i = 48.66776677
j = 48.3333333
response.write(Round(i))
response.write("
")
response.write(Round(j))
%>

</body>
</html>
5.A random number(取随机函数)
<html>
<body>

<%
randomize()
response.write(rnd())
%>

</body>
</html>
6.Return a specified number of characters from left/right of a string
<html>
<body>

<%
sometext="Welcome to this Web"
response.write(Left(sometext,5))
response.write("
")
response.write(Right(sometext,5))
%>

</body>
</html>
7.Replace some characters in a string(字符串的替换)
<html>
<body>

<%
sometext="Welcome to this Web!!"
response.write(Replace(sometext, "Web", "Page"))
%>

</body>
</html>
8.Return a specified number of characters from a string(截取字符串)
<html>
<body>

<%
sometext="Welcome to this Web!!"
response.write(Mid(sometext, 9, 2))
%>

</body>
</html>
9。Return a specified number of characters from a string (取字符串中任意字符)
<html>
<body>

<%
sometext="Welcome to this Web!!"
response.write(Mid(sometext, 9, 2))
%>

</body>
</html>
0

评论Comments

日志分类
首页[223]
javascript[29]
asp[62]
常识[12]
SQL[8]
文学[2]
Dreamweaver[22]
网页设计[25]
flash[20]
片言碎语[21]
php[6]
web standard[16]