vbs选择文件夹效果代码
不用组件的话有两种办法:
set objFile = CreateObject("SAFRCFileDlg.FileOpen")
Set objShell = CreateObject("Shell.Application")
本blog里都有示例。
如果调用vb组件,可以是:
flag = &h200
whichone = OpenFile("Choose a File!", "C:\", "Everything|*.*|TextFiles|*.TXT|Word-Documents|*.DOC", 2, flag)
MsgBox "Raw data returned: " & whichone
' Split up multi selection result:
' space is used as separator:
whichone = Split(whichone, " ")
' field index 0 contains path information:
path = whichone(0)
' list all the files:
' how many files were selected?
filecount = UBound(whichone)
if filecount=0 then
' just one file selected!
MsgBox "You selected one file: " & whichone(0)
' check status of Read Only checkbox
' is bit 1 set or cleared?
' works only if just one file was selected!
MsgBox "Returned flag: " & flag
if (flag and 1) then
' (flag and 1)<>0, transforms to true
' bit is set!
MsgBox "ReadOnly selected!"
else
MsgBox "ReadOnly not selected!"
end If
' check whether selected file is of default type (txt)
if (flag and 1024) then
MsgBox "selected file is no txt file!"
else
MsgBox "selected file is of default type!"
end if
else
' more than one file selected!
MsgBox "You selected " & filecount & " files!"
for x = 1 to UBound(whichone)
list = list & path & whichone(x) & vbCr
next
MsgBox list
end If
function OpenFile(title, dir, filter, index, flags)
set comdlg = CreateObject("MSComDlg.CommonDialog")
comdlg.filter = filter
comdlg.FilterIndex = index
comdlg.Flags = flags
comdlg.MaxFileSize = 260
comdlg.CancelError = false
comdlg.DialogTitle = title
comdlg.InitDir = dir
' set txt as default
comdlg.DefaultExt = "txt"
comdlg.ShowOpen
OpenFile = comdlg.filename
' important: return flag status so your main script can
' check it:
flags = comdlg.Flags
end function
组件相关文件下载 http://xiazai.jb51.net/jbtools/vb6controls.rar
上一篇:vbs Windows系统改变或修改网卡的MAC地址的脚本与软件第1/2页
栏 目:vb
本文标题:vbs选择文件夹效果代码
本文地址:https://www.xiuzhanwang.com/a1/vb/7648.html
您可能感兴趣的文章
- 01-10下载文件到本地运行的vbs
- 01-10VBS中的正则表达式的用法大全 <font color=red>原创&
- 01-10VBS中SendKeys的基本应用
- 01-10VBScript教程 第十一课深入VBScript
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript语法速查及实例说明
- 01-10VBS中Select CASE的其它用法
- 01-10VBScript教程 第七课使用条件语句
- 01-10vbscript 可以按引用传递参数吗?
- 01-10VBScript教程 第二课在HTML页面中添加VBscript代码
阅读排行
本栏相关
- 01-10下载文件到本地运行的vbs
- 01-10飘叶千夫指源代码,又称qq刷屏器
- 01-10SendKeys参考文档
- 01-10什么是一个高效的软件
- 01-10VBS中的正则表达式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本应用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一课深入VBScript
- 01-10VBScript语法速查及实例说明
随机阅读
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 01-10delphi制作wav文件的方法
- 01-11ajax实现页面的局部加载
- 01-10SublimeText编译C开发环境设置
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 04-02jquery与jsp,用jquery
- 01-10C#中split用法实例总结
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文