stringvb.netcommand

Using String variable as an expression


Passing commands as variables. I am creating a POP3 client and was crunching through some code when I though of something interesting.

Is it possible to pass strings of vb code to an object so that the object will execute it. I am relatively familiar with vb.net's source code being converted to Intermediate language and then being thrown into a JIT virtual machine, but I was hoping there was a simple way to implement this idea.

I want to be able to use strings

Dim Command as string 
    Command = "If a + b > 0 then c = a + b" '<----syntactical sugar!
    System.Compiler.Something.execute(command)

If anyone has any direction, or any correction to any of the above. I appreciate your time.

Rah!


Solution

  • As a start you may want to check out the open source FileHelpers project. The Runtime.ClassBuilder class in that project creates a .Net class from text, which can then be used as a normal class.