Home All Groups Group Topic Archive Search About

Execute something stored in a variable

Author
20 Apr 2006 10:05 AM
Mike TI
April 20, 2006

Hi All

Thank you every one for your help, I have now started to get the feel of
VB.Net 2005.

How can I execute something stored in a variable.

For example, I want to store:

UserControl1.Show() or
UserControl2.Show()

in a variable and then execute whatever is in that variable.

Thanks in advance.
Mike TI

Author
20 Apr 2006 10:56 AM
Herfried K. Wagner [MVP]
"Mike TI" <sunset***@hotmail.com> schrieb:
> How can I execute something stored in a variable.
>
> For example, I want to store:
>
> UserControl1.Show() or
> UserControl2.Show()
>
> in a variable and then execute whatever is in that variable.

Dynamic compilation:

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>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
22 Apr 2006 8:11 AM
Mike TI
April 22, 2006

Thank you for your reply. I found the example very difficult to understand
as I am very new to VB.Net.

Incidently, I read about the System.CodeDom namespace in MSDN, however I am
unable to get the example given to work. Does this do what I have in mind ?

*****
Dim start As New CodeEntryPointMethod()
Dim cs1 As New CodeMethodInvokeExpression( _
    New CodeTypeReferenceExpression("System.Console"), _
    "WriteLine", _
    New CodePrimitiveExpression("Hello World!") )
start.Statements.Add(cs1)
*****

Please assist
Mike Ti

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23shqakGZGHA.3740@TK2MSFTNGP03.phx.gbl...
> "Mike TI" <sunset***@hotmail.com> schrieb:
>> How can I execute something stored in a variable.
>>
>> For example, I want to store:
>>
>> UserControl1.Show() or
>> UserControl2.Show()
>>
>> in a variable and then execute whatever is in that variable.
>
> Dynamic compilation:
>
> 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>
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>