Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a folder based on InputBox results 1

Status
Not open for further replies.

alepore

MIS
Jun 25, 2001
27
0
0
US
Extremely new at vbscript.
I found this code to create a static folder......

MsgBox "Folder created:" & CreateFolder("C:\123\test")

Function CreateFolder(folderName)

On Error Resume Next

Dim aFolders: aFolders = Split(folderName,"\")
Dim i
Dim currentFolder
Dim oFSO: Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")

For i = LBound(aFolders) to UBound(aFolders)
currentFolder = currentFolder & aFolders(i) & "\"
If NOT oFSO.FolderExists(currentFolder) Then
oFSO.CreateFolder(currentFolder)
End If
Next 'i

If oFSO.FolderExists(folderName) Then
CreateFolder = True
Else
CreateFolder = False
End If
End Function

Question: How can I take the results of an InputBox and create, for example, "c:\123\INPUTBOX RESULT"

Thanks in advance,
Anthony
 
On Error Resume Next

Dim Answer1, Answer2, Answer3

Set wn = WScript.CreateObject("WScript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("WScript.Shell")

Answer1 = InputBox("Enter the name of the folder you wish to create")

Answer2 = InputBox("Enter the name of the folder you wish to create")

Answer3 = InputBox("Enter the name of the folder you wish to create")

' The following lines will create a folder and two
' subfolders on c: from the answers given in the input
' boxes above

fs.CreateFolder ("c:\" & Answer1)
fs.CreateFolder ("c:\" & Answer1 & "\" & Answer2)
fs.CreateFolder ("c:\" & Answer1 & "\" & Answer2 & "\" & Answer3)

' you could make a folder in d:\shares\sales folder from
' the answer in the first inputbox like this.

fs.CreateFolder ("d:\shares\sales\" & Answer1)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top