1

This was a possibility in VB Script by using a script control with the eval function. For example

ScriptControl1.Eval("(10+1.5)") 'Returns 11.5

Is there a way to do this in Vb.Net? The alternative would be to simply split up the string and verify if it is an addition or a subtracting and work from there. I was just wondering if there's already a built in function that I'm not yet aware of.

Thank you

4

1 に答える 1

1

私はそれを考え出した。次のように、Microsoft Script コントロールへの COM 参照を追加する必要がありました。 ここに画像の説明を入力

次に、新しい変数をスクリプト コントロールとして宣言します。

Dim ScriptControl1 As New MSScriptControl.ScriptControl()
ScriptControl1.Eval("(10+1.5)") ' Returns 11.5

ノート*

ターゲット CPU が x86 であることを確認してください! Any CPU に設定すると、COMException が発生します。

于 2013-04-23T16:57:41.530 に答える