By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,932 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

Is there any way that code stored as a variable in vb can be executed?

P: 1
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
Nov 10 '15 #1
Share this Question
Share on Google+
2 Replies

P: 296
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.
Expand|Select|Wrap|Line Numbers
  1. Dim proc As New System.Diagnostics.Process()
  3. proc = Process.Start("d:\windows\mybatfile.bat", "")
If, however, you are talking about more 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.
I would be curious as to your use-case for this unconventional maneuver?
Jan 13 '16 #2

P: 82
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.
Jan 13 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.