列举某一目录上的所有文件,如:call bianli("c:")
function bianli(path)
set fso=createobject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objSubFolders
if right(path,1)<>"/" then
nowpath=path + "/" + objSubFolder.name
else
nowpath=path + objSubFolder.name
end if
Response.Write nowpath
set objFiles=objSubFolder.Files
for each objFile in objFiles
Response.Write "<br/>"
Response.Write objFile.name
next
Response.Write "<hr>"
if objSubFolder.attributes<>16 then bianli(nowpath)
'bianli(nowpath)
next
Response.Write path1
for each objFile1 in objFolder.Files
Response.Write "<br/>"
Response.Write objFile1.name
next
Response.Write "<hr>"
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
用自定义函数获取汉字的首字母[ZZ,自己收藏]
-----------------------------------------------------------
March 25,2004
<SCRIPT LANGUAGE=vbscript>
<!--
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53640) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
function getpy(str)
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
d="只查"
msgbox getpy(d)
//-->
</SCRIPT>
函数:去掉由逗号分割的字符串(数组也可以)中的重复值
<script language=vbs>
'功能:从很多字串中排除相同字串
'输入:很多字串组成的数组:
dim A,B
A=array("字串1","字串2","字串3","字串1","字串2","字串1","字串4")
'输出:
B=F(A)
'显示结果:B=array("字串1","字串2","字串3","字串4")
for each bbb in B
document.write bbb & "<br/>"
next
'函数部分
function F(x)'这里x是形参
dim S,D
Set D = CreateObject("Scripting.Dictionary")
for each xxx in x
if not d.Exists(xxx) then D.Add xxx,xxx
next
for each key in D.Keys
S=S & key & " "
next
set D=nothing
F=split(trim(S))
end function
</script>
function jaron_replacer(strContent,start_string,end_string,replace_string)
'CMS替换函数:源字符串,前部分,后部分,替换成的字符
'返回被替换后的字符串
jaron_replacer = replace(strContent,mid(strContent,instr(strContent,start_string),instr(strContent,end_string)+len(end_string)-1),replace_string)
end function
function replaceplus(strContent,start_string,end_string,replace_string) '文档中,将所有开始,结束之间的所有字符删除
on error resume next
MARKCOUNTS = ubound(split(strContent,start_string))
PRESTRING = strContent
for i=0 to MARKCOUNTS
STARTMARK=instr(1,PRESTRING,start_string,1)
if STARTMARK=0 then exit for
COMPMARK=instr(1,PRESTRING,end_string,1) + len(end_string)
VerString=mid(PRESTRING,STARTMARK,COMPMARK - STARTMARK)
PRESTRING = replace(PRESTRING,VerString,replace_string)
next
replaceplus = PRESTRING
if err.number<>0 then err.Clear
end function
如果在一段HTML中,你并不知道里面有多少个FLASH,想把他们全部删除。就可以这样用。
strContent = replaceplus(strContent,"<OBJECT","</OBJECT>","")
这个命令可以把HTML代码中所有<object> .... </object>的标记全部删除。