手机
当前位置:查字典教程网 >脚本专栏 >vbs >vbs选择文件夹效果代码
vbs选择文件夹效果代码
摘要:不用组件的话有两种办法:setobjFile=CreateObject("SAFRCFileDlg.FileOpen")SetobjShel...

不用组件的话有两种办法:

setobjFile=CreateObject("SAFRCFileDlg.FileOpen")

SetobjShell=CreateObject("Shell.Application")

本blog里都有示例。

如果调用vb组件,可以是:

flag=&h200

whichone=OpenFile("ChooseaFile!","C:","Everything|*.*|TextFiles|*.TXT|Word-Documents|*.DOC",2,flag)

MsgBox"Rawdatareturned:"&whichone

'Splitupmultiselectionresult:

'spaceisusedasseparator:

whichone=Split(whichone,"")

'fieldindex0containspathinformation:

path=whichone(0)

'listallthefiles:

'howmanyfileswereselected?

filecount=UBound(whichone)

iffilecount=0then

'justonefileselected!

MsgBox"Youselectedonefile:"&whichone(0)

'checkstatusofReadOnlycheckbox

'isbit1setorcleared?

'worksonlyifjustonefilewasselected!

MsgBox"Returnedflag:"&flag

if(flagand1)then

'(flagand1)<>0,transformstotrue

'bitisset!

MsgBox"ReadOnlyselected!"

else

MsgBox"ReadOnlynotselected!"

endIf

'checkwhetherselectedfileisofdefaulttype(txt)

if(flagand1024)then

MsgBox"selectedfileisnotxtfile!"

else

MsgBox"selectedfileisofdefaulttype!"

endif

else

'morethanonefileselected!

MsgBox"Youselected"&filecount&"files!"

forx=1toUBound(whichone)

list=list&path&whichone(x)&vbCr

next

MsgBoxlist

endIf

functionOpenFile(title,dir,filter,index,flags)

setcomdlg=CreateObject("MSComDlg.CommonDialog")

comdlg.filter=filter

comdlg.FilterIndex=index

comdlg.Flags=flags

comdlg.MaxFileSize=260

comdlg.CancelError=false

comdlg.DialogTitle=title

comdlg.InitDir=dir

'settxtasdefault

comdlg.DefaultExt="txt"

comdlg.ShowOpen

OpenFile=comdlg.filename

'important:returnflagstatussoyourmainscriptcan

'checkit:

flags=comdlg.Flags

endfunction

组件相关文件下载http://xiazai.jb51.net/jbtools/vb6controls.rar

【vbs选择文件夹效果代码】相关文章:

vbs 调用中文语音让你电脑听你的命令的实现代码

用vbscript合并多个文本文件的代码

用vbscript实现从文本文件中删除所有重复行的代码

支持断点下载的VBS代码

vbscript 三个数比较大小的实现代码

用vbs实现判断计算机是笔记本还是台式机的代码

vbs定时发送邮件的方法与代码

用vbs计算某个词在日志文件中的出现次数

vbs通过WMI修改文件文件夹的NTFS权限

QueryCode.vbs 文本文件编码查询工具

精品推荐
分类导航