I want to be able to store my code for a program in a text file or store it as a string in a variable and use a function to execute that code. If anyone knows a way to do this or something similar it would be a great help. Thanks
Is there any way that code stored as a variable in vb can be executed?
Collapse
X
-
If you are talking about something like batch-file code, or perl or PHP code you can write out as necessary and then call it so that an installed interpreter can "run" it - then yes. Just write it out to a file (with appropriate extension then call it like you would any external program.
Example:
If, however, you are talking about more vb.net code that would be part of your compiled program - then no. I do not know of any way this can be done - and doubt if it would even be possible.Code:Dim proc As New System.Diagnostics.Process() proc = Process.Start("d:\windows\mybatfile.bat", "")
I would be curious as to your use-case for this unconventional maneuver? -
It is possible to compile VB Code and run the code in memory or compile the code to an exe file and then run it from a string containing the code in your application.
However, i would also be interested in the use of this a bit more before i explain any further.Comment
Comment