使用 VB 计算字符串中的数学表达式 [英] Evaluate mathematical expression from a string using VB

查看:18
本文介绍了使用 VB 计算字符串中的数学表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 VB 计算一个字符串的算术表达式,有什么想法吗?

I want to calculate a arithmetic expression from a string using VB, any ideas ?

例如:文本框中的x+2",我想计算表达式

As an example : "x+2" from a textbox, I want to evaluate the expression

推荐答案

你可以使用NCalc 为此.它还接受像 x, y, z,...

you can use NCalc for this. It also accepts parameters like x, y, z,...

Dim e As Expression = new Expression("2 + 3 * 5")
Msgbox(17 = e.Evaluate())

这篇关于使用 VB 计算字符串中的数学表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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