简体   繁体   English

VB.NET。 如何将文本框输入或字符串转换为算术公式?

[英]VB.NET. How to convert a textbox input or a string into an arithmetic formula?

I am trying to create a grading system where you can choose your own subject and components(recitation, quiz etc) and as well as customize the formula... I will be using ddl language to create the fields and tables in the database so all's well with that, however, I have a big problem with the formula... I do not know how I can convert the string formula (from the textbox or the database) containing "variable names" into a workable formula that the system will recognize. 我正在尝试创建一个评分系统,您可以选择自己的主题和组件(背诵,测验等),以及自定义公式...我将使用ddl语言在数据库中创建字段和表,所以所有的与此相关的是,我的公式存在很大问题...我不知道如何将包含“变量名”的字符串公式(从文本框或数据库中)转换为系统将识别的可行公式。

short example. 简短的例子。

I declare three integers a, b & c with corresponding values (a =1, b=2, c=3). 我声明了三个整数a,b和c以及相应的值(a = 1,b = 2,c = 3)。 then let the user input a formula in a textbox. 然后让用户在文本框中输入公式。

example: textbox1: a+c 示例:textbox1:a + c

then equate the results using b... 然后使用b等于结果...

this is where the problem lies, the program reads it as plain string and does not recognize the variable DX 这就是问题所在,程序将其读作纯字符串并且不识别变量DX

How will I do this? 我该怎么做?

Some libraries which can evaluate simple math expression strings in .NET are: 一些可以在.NET中评估简单数学表达式字符串的库是:

Hope I helped! 希望我帮忙!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM