|
我的asp学习笔记-Some Other Functions (VBScript) |
Author:咖啡虫 PublishTime:2004-6-15 |
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>
|
| | |