FSO的强大功能

2019-04-02 11:53:44丽君

dim sel,mytext 
set sel = document.selection.createRange() 
'txt.createTextRange 
mytext = sel.text 
if len(mytext)=0 then 
sel.text =string(4," ") 
window.event.cancelBubble = true 
window.event.returnValue = false 
exit sub 
end if 
dim t,Arr 
t=0 
Arr = split(mytext,vbcrlf) 
if window.event.shiftKey then 
'按sift 
for i=0 to ubound(Arr) 
if left(Arr(i),1)=vbtab then 
Arr(i) = mid(Arr(i),2) 
t= t + 1 
else 
for j=1 to 4 
if left(Arr(i),1)=" " then 
Arr(i) = mid(Arr(i),2) 
t= t + 1 
else 
exit for 
end if 
next 
end if 
next 
t= t 
else 
'不按sift 
for i=0 to ubound(Arr) 
Arr(i) = vbtab & Arr(i) 
t= t +1 
next 
end if 
mytext = join(Arr,vbcrlf) 
sel.text = mytext 
sel.collapse true 
sel.moveEnd "character",0 
sel.moveStart "character",(len(mytext) * -1) + t 
sel.select() 
window.event.cancelBubble = true 
window.event.returnValue = false 
end sub 
'下面是关于搜索 
dim seachResult'查找结果 
dim num '结果数量 
dim word'搜索关键字 
tagStop = false 
seachResult ="" 
sub seachFile() 
num =0 
seachList.innerText = "搜索结果" 
word = searchKey.value 
seachResult ="" 
if trim(word)="" then 
alert "关键字为空!" 
searchKey.focus 
exit sub 
else 
dim l 
for each l in list.getElementsByTagName("DIV") 
if l.id<>"seachList" then list.removeChild l 
next 
seachList.innerText = "搜索结果" 
seachWord thisFileFolder 
seachList.insertAdjacentHTML "AfterEnd",seachResult 
seachList.innerText = "搜索结果:" & num & "个" 
alert "搜索完毕!" 
end if 
end sub 
sub seachWord(theFolder) 
dim f,f1,st,re,fd,fd1 
set f = fso.GetFolder(theFolder) 
for each f1 in f.Files 
if isTxt(f1.name) then 
if instr(f1.name,word)>0 then 
seachResult = seachResult & "<div class='file' title='" & f1.path