从文本文件执行vb.net代码并返回值 [英] Executing a vb.net code from text file and returning value

查看:92
本文介绍了从文本文件执行vb.net代码并返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我想在运行时使用.net FW 4.0从文件执行数学表达式,如果任何正文可以共享代码,那将是非常的很有帮助。



要求: -

我在一个文本文件中存储了一个函数: -



函数add(ByVal a As Int16,ByVal b As Int16)As Int32

返回(a + b)

结束函数



&i必须传递a&b的值并且必须在我的主程序中获得返回值(即a + b)。

__________________________

提前谢谢

Dear all,

I want to execute mathematical expressions from file at runtime using .net FW 4.0, If any body can share the code, It will be very helpful.

Requirement:-
I have stored a function in a text file:-

Function add(ByVal a As Int16, ByVal b As Int16) As Int32
Return (a + b)
End Function

& i have to pass the value of a &b and 've to get the return value(i.e. a+b) in my main program.
__________________________
Thanks in advance

推荐答案

如果您只想评估数学运算,那么执行VB代码就太过分了。看看这个:

Math Parser .NET C# [ ^ ]你喂它字符串,它返回结果。



虽然你可以从一个程序中编译和执行VB代码,但它要复杂得多,而且更危险(因为它可以访问所有.NET方法,这可能根本不是你想要的!)
If all you want to do is evaluate mathematical operations, then executing VB code is overkill. Have a look at this:
Math Parser .NET C#[^] You feed ita string, it returns the result.

While you can compile and execute VB code from within a program, it is a lot more complex to do, and a lot more dangerous (since it will have access to all the .NET methods, which is probably not what you want at all!)


为此我们可以使用
Quote:

CodeDOM



&相同的链接是: -




& the link for the same is:-

Quote:

CodeDOM


这篇关于从文本文件执行vb.net代码并返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆