Executing code - PLEASE HELP 
Author Message
 Executing code - PLEASE HELP

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!!!



Tue, 21 Jan 2003 03:00:00 GMT  
 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!!!



Tue, 21 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. PLEASE HELP PLEASE HELP PLEASE HELP

3. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

4. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

5. eval to execute - sub - Please Help.

6. Please help: Execute Typ MisMatch

7. HELP: Can't execute code from a freed script

8. .chm files and executing code on mapped drives (via javascript coded object)

9. API callbacks - need help / example code - PLEASE PLEASE!!!

10. please help with creating controls while the program is executing

11. vb5: Inet1.Execute and FTP (please help)

12. Shell execute help please.

 

 
Powered by phpBB® Forum Software