Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one string

dim strValue as string="If 2<4 then 4 else 6"

and i have to convert to vb code like our code behind work

like

if 2<4 then 4 else 6 and i want my answer =6



Please Help me
Thank in advance
Posted
Comments
OriginalGriff 26-Jul-12 3:13am    
And what have you tried?
hareshdgr8 26-Jul-12 3:34am    
nothing i have to do somthing but i am stuck about how to convert to vb editor mode please help me
OriginalGriff 26-Jul-12 3:39am    
You can't convert running code to "vb editor mode" - that doesn't exist. There are a number of things you could do, but what are you actually trying to achieve?
Are you trying to get a client to enter code that you then execute directly on the server?
hareshdgr8 26-Jul-12 3:41am    
Yes actually client will enter if else condition like in excel we can enter if else statement i have to achieve like that excel things please help me
hareshdgr8 26-Jul-12 4:18am    
your link is meaningless i didn't understood. is it useful for me

1 solution

Executing code directly is possible - you can use the compiler built into .NET top compile and execute code, but it is a very bad idea to try, as it exposes the whole of the .NET framework to your user, which would give them complete control of your server - not a good idea unless you can absolutely trust every single person who might ever access your site. And I don't trust any of them!

The other problem with that approach is that it requires the user to enter the code in a .NET language, with all the syntax that that requires.

I think that you are going to have to parse it yourself, and process the commands yourself - it's basically a whole macro language you want to add!

This might help - but don't expect this to be particularly quick! http://msdn.microsoft.com/en-us/magazine/cc164072.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900