
Executing code - PLEASE HELP
You can simply do it by:
ExecuteGlobal("Dim " & sVarName)
' this puts the Dimmed variable in the global namespace of the script.
and if this doesn't word you could try:
result = Eval("Dim " & sVarName)
if result then
' OK
else
' NOT OK
end if
Quote:
> Hi! Here's my problem:
> 1. A string-variable is passed as an argument to a function.
> 2. In this function I want to declare a variable with the name of the
> argument.
> Example:
> ____________________________________
> Function StupidExample (sVarName)
> Dim sVarName
> End Function
> StupidExample ("sString")
> ____________________________________
> My problem is declaring the variable inside the function.
> Is there some way to execute code like this:
> Execute ("Dim " sVarName)
> In JScript this is not a problem, but I rather do it in VBScript.
> Thanks!!!