Hello Everyone
I am trying to write a little utility using hta as the GUI for vbscript. I am trying to pass a variable form one function to another function in the same program. here is my code
'-----------------------------------------------------------
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objShell
Set objShell = CreateObject("WScript.shell"
'-----------------------------------------------------------
Function builddir(strChgDir)
Dim strCmd1, strDir
strDir = strChgDir
If strDir = "" Then
strDir = "H:\"
End If
strCmd1 = "cmd.exe /C dir /B /A /S " & strDir & " >C:\Temp\tmpdirlist.txt"
objShell.run strCmd1, 1, TRUE
End Function
'-----------------------------------------------------------
Function chngdir()
Dim strChgDir
strChgDir = InputBox("Enter new Drive letter to Browse"
MsgBox "You are going to Browse " & strChgDir
End Function
'-----------------------------------------------------------
'Call builddir() Function to execute
builddir(strChgDir)
'-----------------------------------------------------------
I get an error with this code. The debugger reports that I have an undefined variable and the spot where I call the function to execute is highlighted by the debugger. If I attempt to define this variable in the builddir() function I get a different error message "Name Redefined" and the debugger highlights the Dim line in the builddir() function. Any help someone can give to me will be greatly appreciated.
Thanks Randy
I am trying to write a little utility using hta as the GUI for vbscript. I am trying to pass a variable form one function to another function in the same program. here is my code
'-----------------------------------------------------------
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objShell
Set objShell = CreateObject("WScript.shell"
'-----------------------------------------------------------
Function builddir(strChgDir)
Dim strCmd1, strDir
strDir = strChgDir
If strDir = "" Then
strDir = "H:\"
End If
strCmd1 = "cmd.exe /C dir /B /A /S " & strDir & " >C:\Temp\tmpdirlist.txt"
objShell.run strCmd1, 1, TRUE
End Function
'-----------------------------------------------------------
Function chngdir()
Dim strChgDir
strChgDir = InputBox("Enter new Drive letter to Browse"
MsgBox "You are going to Browse " & strChgDir
End Function
'-----------------------------------------------------------
'Call builddir() Function to execute
builddir(strChgDir)
'-----------------------------------------------------------
I get an error with this code. The debugger reports that I have an undefined variable and the spot where I call the function to execute is highlighted by the debugger. If I attempt to define this variable in the builddir() function I get a different error message "Name Redefined" and the debugger highlights the Dim line in the builddir() function. Any help someone can give to me will be greatly appreciated.
Thanks Randy