lab2bc3cd4de5e") &; "
" response.write"ucase 函数:alab2bc3cd4de5e 的大小写形式是" &; uase("alab2bc3cd4de5e") &; "
" response.write" left 函数:vbscript 字左边算起的 4 个字符是" &; left("vbscript",4) &; "
" response.write"right 函数:vbscript 自右边算起的 4 个字符是" &; right("vbscript",4) &; "
"
response.write"mid 函数:vbscript 自第二个字符开始的 4 个字符是" &; mid("vbscript",2"4) &; "
" response.write"len 函数:中文 vbscript 的长度是" &; len("中文 vbscript") &; "
" response.write"ltrim 函数:删除字符串(" &; str &; ")左边的空格为(" &; ltrim(str) &; ")
" response.write"rtrim 函数:删除字符串(" &; str &; ")右边的字符串为(" &; rtrim(str) &; ")
" response.write"trim 函数:删除字符串(" &; str &;" )两边的空格为(" &; trim(str) &; ")
" response.write"replace 函数:替换字符串" &; searchstring &; "中" &; "p" &; "为 cc 的结 果是" &; replace(searchstring, "p","cc") &; "
" response.write"space 函数:hello 和 world 之间插入 10 个空格是" &; "hello" &; space(10) &; "world" &; "
" response.write"strcomp 函数:ABCD 和 abcd 比较结果" &; strcomp("","abcd") &; "
" response.write"string 函数:由 5 个*组成的字符串是" &; string(5, "*") &; "
" response.write"strreverse 函数:vbscript 反写是" &; strreverse("vbscript") &; "
" %> (下面 ASP 网页的例子示例 vbscript 数组运行) <% response.write"
" dim A A=array(10,20,30) dim x(9) response.write"array 函数: A=array(10,20,30)定义数组,A(2)是" &; A(2) &; "
" response.write"ubound 函数:dim x (9) 1 维数上标是 " &; ubound (x ,1) &; "
" response.write"lbound 函数:dim x (9)1 维数下标是" &; lbound (x,1) &; "
"
redim A (10,30,6) response.write"ubound 函数:redim A (10,30,6)1 维数是" &; ubound(A,1) &;"
" response.write"ubound 函数: redim A (10,30,6)2 维数是" &; ubound(A,2) &;"
" response.write"ubound 函数: redim A (10,30,6)3 维数是" &; ubound(A,3) &;"
" response.write"lbound 函数:redim A (10,30,6)1 维数是" &; lbound(A,1) &;"
" response.write"lbound 函数:redim A (10,30,6)2 维数是" &; lbound(A,2) &;"
" response.write"lbound 函数:redim A (10,30,6)3 维数是" &; lbound(A,3) &;"
" %> (2)VBscript 编程 下面 ASP 网页的
例子计算 1+2+3+.....+100 之和 <% i=0 s=0 while<=100 i=i+1 s=s+i wend response.write"1+2+3+.....+100 的结果是" &; s %> 下面 ASP 网页的例子求 100 以内的素数 <% response.write"100 以内的素数
" cnt=o for i=2 to 100
for j=2 to i-1 if (i mod j)=0 then next if (j>=i) then if cnt>=10 then response.write"
" cnt=o end if response.write i &; "," cnt=cnt+1 end if next %> 下面 ASP 网页的例子计算出 100 到 500 的之间的水仙花束 <% response.write"
" for i=100 to 500 a=i\100 b=i\10 mod 10 c=i\1 mod 10 if (a*a*a+b*b*b+c*c*c)=i then response.write i &; "," end if next exit for
%> 下面 ASP 网页例子将 3x3 矩阵转置 <% dim A(3,3) response.write "原 3X3 矩阵
" cnt=1 for i=1 to 3 for j=1 to 3 A(i,j)=cnt cnt=cnt+1 response.write A(i,j) &; " " next response.write"
" next for i=1 to 3 for j=1 to i-1 t=A(i,,j) A(i,,j)=A(j,i) A(j,i)=t next next response.write"转置新 3X3 矩阵
" for i=1 to 3 for j=1 to 3
response.write A(i,j) &; " " next response.write "
" next %> 下面 ASP 网页的例子对数组采用冒泡法排序 <% sub sort(arr( ),length dim i,j,inttmp for i=0 to length for j=0 to length if arr(i)> arr(j) then inttmp=arr(i) arr(i)=arr(j) arr(j)=inttmp end if next next end sub dim intarr(9) randomize(time( ) ) for i=0 to 9 intarr(i)=int(rnd( ) *25+1) next
response.write"排序前的数组
" for i=0 to 9 response.write intarr(i) &; " " next sort intarr,9 '排序 response.wri