国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

vbs選擇文件夾效果代碼

2020-06-26 18:16:47
字體:
來源:轉載
供稿:網友
非常不錯的用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  
上一篇:用vbs實現選擇顏色

下一篇:vbs的sort排序

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴南区| 翼城县| 海阳市| 舒城县| 沈丘县| 河曲县| 嘉峪关市| 互助| 上蔡县| 大渡口区| 石林| 沙河市| 夏河县| 天柱县| 理塘县| 且末县| 兴宁市| 桐柏县| 加查县| 乌拉特后旗| 宁都县| 徐州市| 鄂托克前旗| 城步| 莱芜市| 哈密市| 齐河县| 衡阳县| 丁青县| 东乌珠穆沁旗| 尚义县| 方山县| 万全县| 正安县| 上虞市| 白沙| 沁源县| 稷山县| 安化县| 郸城县| 虞城县|