將數(shù)學(xué)技巧加入到您的應(yīng)用程序中,Eval是一個表達式計算器庫。它能解析幾乎所有的Visual Basic表達式。您既可以接受用戶的表達式,又可以計算出一次簡單調(diào)用的結(jié)果。
Power up your apps with math skills!Eval is an expression evaluator library. It evaluates almost any Visual Basic expression. You can accept expressions from the users and calculate the result with a simple call.
Eval是一個表達式計算器庫。它能解析幾乎所有的Visual Basic表達式。您既可以接受用戶的表達式,又可以計算出一次簡單調(diào)用的結(jié)果。以下是一些在您的應(yīng)用程序可能會用到的功能例子:
- 計算 “1+2+3” 這樣一個簡單的數(shù)學(xué)公式。
- 接受任何諸如“x + y^2”這樣的方程式,替換變量值并獲得結(jié)果。
- 使用用戶定義的公式來繪制曲線。
- 構(gòu)建您自己的計算器。
- 可將表達式添加到您的編程語言或宏系統(tǒng)中。
Eval的使用非常簡單,這里有一個例子。
公式= Textbox.Text ‘接受用戶輸入,例如“1+2+3”
結(jié)果= Eval(公式) ‘結(jié)果為6
支持的表達式
Eval可以處理Visual Basic中所有的常數(shù)表達式:
- 數(shù)字(十進制,八進制和十六進制)和字符串
- 數(shù)字運算:所有算術(shù)、比較和邏輯運算符(+ - * / \ ^ Mod, 等)
- 支持字符串連接并可使用運算符Like進行比較
- 支持關(guān)鍵字Empty和Null
- 支持基本單參數(shù)函數(shù)如CInt(), Abs() or Sgn()
Eval包含了一個支持變量的簡單接口。另外您還可以通過增加更多的函數(shù)來擴展模塊。
模塊信息
Eval為Visual Basic 5.0和6.0提供了一個普通的源代碼模塊(Eval.bas),還有一個是為VBCE6.0提供的版本。它不需要任何特定的Windows版本或運行時文件。
目前暫不支持VB.NET。在某種程度上,Eval不容易升級到支持VB.NET的版本。
Eval is an expression evaluator library. It evaluates almost any Visual Basic expression. You can accept expressions from the users and calculate the result with a simple call. A few examples of what you application might do:
- Calculate a simple mathematical formula like "1+2+3".
- Accept any formula like "x + y^2", substitute variable values and get the result.
- Draw curves from user-defined formulas.
- Build your own calculator.
- Add expressions to your own programming language or macro system.
Eval is simple to use. Here is an example.
Formula = Textbox.Text ' Accept input from the user, example: "1+2+3"
Result = Eval(Formula) ' Result will be 6
Supported expressions
Eval can handle all Visual Basic constant expressions:
- Numbers (decimal, octal, hexa) and string literals
- Numeric operators: all arithmetic, comparison and logical operators (+ - * / \ ^ Mod, etc.)
- String concatenation and Like
- The keywords Empty and Null
- Basic single-argument functions like CInt(), Abs() or Sgn()
Eval contains an easy interface to support variables. You can also extend the module by adding more functions.
Module information
Eval comes as an ordinary source code module (Eval.bas) for Visual Basic 5.0 and 6.0. There is also a version for VBCE 6.0. It doesn't require any specific Windows version or run-time files.
VB.NET support is currently not available. Eval is written in a way that is not easily upgraded to VB.NET.