Valhalla Legends Forums Archive | Visual Basic Programming | Treat a String as Code

AuthorMessageTime
Soul Taker
I may be overthinking this and missing an obvious way, but how do I treat a string as code to be executed?
For instance, say I have a string containing "Call SomeFunction(Param, Param2)";  how do I then actually execute the code contained in the string?
November 24, 2004, 10:07 AM
Myndfyr
You would need to implement scripting.  I do not believe that this is otherwise inherently supported in Visual Basic; in JavaScript or PHP, you can use the eval() function to treat a string as code.
November 24, 2004, 10:25 AM
K
not without using the microsoft script control
November 24, 2004, 7:02 PM
UserLoser.
You might be able to use CallByName
November 24, 2004, 7:31 PM
Soul Taker
>:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.
November 25, 2004, 12:49 PM
kamakazie
[quote author=Soul Taker link=topic=9660.msg89984#msg89984 date=1101386967]
>:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.
[/quote]

Well what is it you're really trying to accomplish?  Perhaps it can be done in way to use CallByName?
November 25, 2004, 2:07 PM
Soul Taker
[quote author=dxoigmn link=topic=9660.msg89988#msg89988 date=1101391655]
[quote author=Soul Taker link=topic=9660.msg89984#msg89984 date=1101386967]
>:(
Doesn't look like CallByName would work for what I want.
Guess I'm going to have to skip this and find some complicated way to do it, thanks.
[/quote]

Well what is it you're really trying to accomplish?  Perhaps it can be done in way to use CallByName?
[/quote]
The only time I've used CallByName was to call control properties.  Unless it can be used for user-defined functions, it won't be useful to me.
I'm working on a workaround now anyway.  Sadly, it won't be as effective as just buffering a bunch of function calls into a string array and then quickly calling them like I wanted to, but it should do pretty much what I intended.
November 25, 2004, 4:21 PM

Search