In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to choose a folder dialog box in vbs,hta, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The code is as follows:
On error resume next
SelectFolder
Function SelectFolder ()
Const MY_COMPUTER = & H11 &
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace (MY_COMPUTER)
Set objFolderItem = objFolder.Self
StrPath = objFolderItem.Path
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.BrowseForFolder (WINDOW_HANDLE, "Select text plus folder:", OPTIONS, strPath)
If objFolder Is Nothing Then
Msgbox "you have not selected any valid directories!"
End If
Set objFolderItem = objFolder.Self
ObjPath = objFolderItem.Path
Msgbox "the folder you selected is:" & objPath
End function
But this code can not be used in hta, because there are not enough permissions, I don't know if it can be used on other machines.
So I wrote a folder selection code with the combination of vbs's own function and fso, for reference only.
The copy code is as follows:
Dim spath
Spath= "Root"
Function SFolder ()
On error resume next
Dim fso, drv, f, fc, nf, s, i, p, r, d
ITunes 3
If spath= "Root" then
Set fso = CreateObject ("Scripting.FileSystemObject")
Set drv = fso.Drives
S = "enter serial number to enter, serial number + # to check (c is cancel)" + chr (13) + chr (10)
Root directory + chr (13) + chr (10)
Upper layer + chr (13) + chr (10)
For Each an In drv
S=s+cstr (I) + "." + a.Path+chr (13) + chr (10)
I=i+1
Next
GetD s
Else
Set fso = CreateObject ("Scripting.FileSystemObject")
If right (spath,1) "\" then
Spath=spath+ "\"
End if
Set fc = fso.GetFolder (spath) .SubFolders
S = "enter serial number to enter, serial number + # to check (c is cancel)" + chr (13) + chr (10)
Root directory + chr (13) + chr (10)
Upper layer + chr (13) + chr (10)
For each nf in fc
S=s+cstr (I) + "." + nf+chr (13) + chr (10)
I=i+1
Next
GetF s
End if
End function
Function GetD (s)
On error resume next
P=inputbox (s, ",")
If p = "c" then
Exit function
End if
R=split (sMagnechr (13) + chr (10))
If right (pmae1) = "#" then
If left (pjinlen (p)-1) = 1 then
Msgbox "this is the root directory, you cannot select the root directory!"
GetD s
Elseif left (pjinlen (p)-1) = 2 then
Msgbox "this is the root directory, you cannot select the root directory!"
GetD s
Else
D=split (r (left (pforce len (p)-1)), ".")
Msgbox "Select:" & d (1)
Document.forms ("ValidForm") .FPath.Value=d (1)
Spath= "Root"
End if
Else
If pendant 1 then
Msgbox "is already the root directory!"
GetD s
Elseif pendant 2 then
Msgbox "is already at the top!"
GetD s
Else
D=split (r (p), ".")
Spath=d (1)
'msgbox' enters: & d (1)
SFolder
End if
End if
End function
Function GetF (s)
On error resume next
P=inputbox (s, ",")
If p = "c" then
Exit function
End if
R=split (sMagnechr (13) + chr (10))
If right (pmae1) = "#" then
If left (pjinlen (p)-1) = 1 then
Msgbox "this is the root directory, you cannot select the root directory!"
GetD s
Elseif left (pjinlen (p)-1) = 2 then
GetTheParent = CreateObject ("Scripting.FileSystemObject") .GetParentFolderName (spath)
Msgbox "Choice:" & GetTheParent
Document.forms ("ValidForm"). FPath.Value=GetTheParent
Else
D=split (r (left (pforce len (p)-1)), ".")
Msgbox "Select:" & d (1)
Document.forms ("ValidForm") .FPath.Value=d (1)
Spath= "Root"
End if
Else
If pendant 1 then
Spath= "Root"
SFolder
Elseif pendant 2 then
GetTheParent = CreateObject ("Scripting.FileSystemObject") .GetParentFolderName (spath)
If GetTheParent= "" then
Spath= "Root"
'msgbox' enter: root directory
Else
Spath=GetTheParent
'msgbox' enters: & GetTheParent
End if
SFolder
Else
D=split (r (p), ".")
Spath=d (1)
'msgbox' enters: & d (1)
SFolder
End if
End if
End function
The above is all the contents of the article "how to choose a folder dialog box in vbs,hta". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.