Convert a string to code

  • Thread starter Thread starter Andrew Cranwell
  • Start date Start date
A

Andrew Cranwell

Hi,

I wanted to know if it is possible to convert a string into a code
expression, like you can with JavaScript's 'Eval' statement.

For example,

If I have a string such as "Dim A As New RandomObj()", can I turn this into
code in some way?

Many thanks,

Andrew
 
Andrew Cranwell said:
I wanted to know if it is possible to convert a string into a code
expression, like you can with JavaScript's 'Eval' statement.

For example,

If I have a string such as "Dim A As New RandomObj()", can I turn this
into
code in some way?

No, not really. What you request is a feature typically available in
interpreted (scripting) languages. VB.NET is typically a compiled language
and thus doesn't provide intrinsic support for dynamically evaluating code.
However, it's actually possible to execute code dynamically at runtime:

Build a Custom .NET "EVAL" Provider
<URL:http://www.eggheadcafe.com/articles/20030908.asp>

Runtime Compilation (A .NET eval statement)
<URL:http://www.codeproject.com/dotnet/evaluator.asp>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top