实验三 编写 ASP 程序
2008 年 05 月 09 日 星期五 11:50
2.VBscript
程序设计 (1)Vbscript 函数调用 【[ASP 网页的例子示例 VBScript 日期时间函数运行】 (vbscript 函数调用) <% dim thedate thedate =#october 19,1962# '指定日期。
response.write"日期时间函数运行结果
" response.write“date 函数:当前系统日期是" &;date &;"
" response.write"dateadd 函数:1995 年 1 月 31 日一个月后是" &;dateadd("m",1, "31-jan-95") &;"
" response.write"datediff 函数:1962.10.19 日以来的天数是" &; datediff("d", thedate,now) &;"
" response.write":" &;datepart 函数:今天是第"&;datepart("q",now) &;"季度
" response.write"day 函数:1962.10.19 的日期" &;day("october19,1962" &;"
" response.write"hour 函数:现在是" &;hour(now)&;"点
" response.write"minute 函数:当前分是" &;minute(now) &;"月
" response.write"month 函数:现在是" &;month(now) &;"月
" rosponse.write"monthname 函数:这个月是" &;monthname(month(now),true) &;"
" response.write"now 函数:当前
系统日期和时间是"&;now&;"
" response.write"second 函数:当前秒是"&;second(now)&;"
" response.write"time 函数:当前系统时间是"&;time&;"
" response.write"timer 函数:至午夜 12 是已经过去的秒数是"&;timer&;"
"
response.write"weekday 函数:今日为星期"&;weeday(now)&;"
" response.write"year 函数:今年是"&;year(now)&;"
" %> (下面 ASP 网页的例子示例 vbscript 数字函数运行) <% pi=3.1415926 response.write"数学函数运行结果
" response.write"abs 函数:5.3 的绝对值是" &; abs(5.3) &; ",-5.3 的绝对值是" &; abs(-5.3) &; "
" response.write"ath 函数:1.0 反正切之角度是" &; ath(1)*180\pi &; "
" response.write"cos 函数:cos(60 度)"是 &; cos(60*pi/180.0) &; "
" response.write"sin 函数:sin(30 度)是" &; sin(30*pi/180.0) &; "
" response.write" tan 函数:tan(45 度)是" &; tan(45*pi/180.0) &; "
" response.write"exp 函数:e 自然对数是" &; exp(1) &; "
" response.write"fix 函数:99.2 删除小数后市" &; fix(99.2) &; ",-99.2 删除小数是" &; fix(-99.2) &; "
" response.write"int 函数:不大于 99.2 的整数是" &; int(99.2) &; ",不大于-99.2 的整数是 " &; int(-99.2) &; "
" response.write"log 函数:5.0 的自然对数是" &; log(5.0) &; ",5.0 以 10 为底的对数" &; log(5.0)/log(10) &; "
" randomize'初始化随机数生成器 response.write"rnd 函数:一个随机数是" &; rnd( ) &; ",在 10-20 之间的一个随机基数是" &; int( (20-10+1)*rnd+10) &; "
" response.write"sgnhanshu :sgn(12)是 " &; sgn(12) &; ",sgn(-2.4)是" &; sgn(-2.4) &; ",sgn(0)是" &; sgn(0) &; "
" response.write"sqr 函数:4 的平方根是" &; sqr(4) &; ",23 的平方根是" &; sqr(23) &; "
"
response.write"round 函数: 3.14159 四舍五入到两位小数是" &; round(pi, 2) &; "
" %> (下面 ASP 网页的例子示例
VBscript 字符函数运行) <% dim searchstring, searchchar searchstring="xxpxxpxxpxxp" str="vbscript" response.write"字
符函数运行结果
" rosponse.write"asc 函数:apple 第一个字母对应的 anst 字符代码是" &; asc("apple") &; "
" response.write"hex 函数:459 的 16 进制数字符是" &; hex(459) &; ",10 的 16 进制数字符 是" &; hex(10) &; "
" response.write"oct 函数:459 的 8 进制数字符是" &; oct(459) &; ",8 的 8 进制数字符是" &; oct(8) &; "
" response.write"instr 函数:" &; searchstring &; "字符串中" &; "p" &; "出现在" &; instr(1, searchstring,"p",1) &; "位置上
" response.write"instrrev 函数:" &; searchstring &; "字符串中逆向" &; "p" &; "出现在" &; instrrev(searchstring,"p",12,0) &; "位置上
" response.write"lcase 函数:alab2bc3cd4de5e 的小写形式是" &; lcase("a