Skip to content

Commit a0fe77e

Browse files
committed
Update README.md
1 parent 503d42d commit a0fe77e

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

README.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
[![GitHub](https://img.shields.io/github/license/ws-garcia/VBA-Expressions?style=plastic)](https://github.com/ws-garcia/VBA-Expressions/blob/master/LICENSE) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/ws-garcia/VBA-Expressions?style=plastic)](https://github.com/ws-garcia/VBA-Expressions/releases/latest)
33

44
## Introductory words
5-
VBA Expressions is a powerful string expressions evaluator for VBA, focused on mathematical ones. The `VBAexpressions.cls` class serves as an intermediary between user interfaces and the main VBA/custom functions exposed through it. The main development goal of the class is to integrate it with [CSV Interface](https://github.com/ws-garcia/VBA-CSV-interface), with as minimal programming effort as possible, and to allow users to perform complex queries from CSV files using built-in and custom functions.
5+
VBA Expressions is a powerful string expression evaluator for VBA, which puts more than 60 mathematical, financial, date-time, logic and text manipulation functions at the user's fingertips. The `VBAexpressions.cls` class mediates almost all VBA functions as well as custom functions exposed through it.
6+
7+
Although the main development goal of the class was the integration with [CSV Interface](https://github.com/ws-garcia/VBA-CSV-interface), VBA Expressions has evolved to become a support tool for students and teachers of science, accounting and engineering; this due to the added capability to solve systems of equations and non-linear equations in one variable.
68

79
## Advantages
810
* __Easy to use and integrate__.
911
* __Basic math operators__: `+` `-` `*` `/` `\` `^` `!`
1012
* __Logical expressions__: `&` (AND), `|` (OR), `||` (XOR)
1113
* __Binary relations__: `<`, `<=`, `<>`, `>=`, `=`, `>`, `$` (LIKE)
12-
* __More than 20 built-in functions__: `Max`, `Min`, `Avg`, `Sin`, `Ceil`, `Floor`...
13-
* __Very flexible__: variables, constants and user-defined functions (UDFs) support.
14+
* __More than 60 built-in functions__: `Max`, `Sin`, `IRR`, `Switch`, `Iff`, `DateDiff`, `Solve`, `fZero`, `Format`...
15+
* __Very flexible and powerful__: variables, constants and user-defined functions (UDFs) support.
1416
* __Implied multiplication for variables, constants and functions__: `5avg(2;abs(-3-7tan(5));9)` is valid expression; `5(2)` is not.
1517
* __Evaluation of arrays of expressions given as text strings, as in Java__: curly brackets must be used to define arrays`{{...};{...}}`
1618
* __Floating point notation input support__: `-5E-5`, `(1.434E3+1000)*2/3.235E-5` are valid inputs.
@@ -92,19 +94,11 @@ Sub AddingNewFunctions()
9294
End Sub
9395
```
9496
## Working with arrays
95-
VBA expressions can evaluate matrix functions whose arguments are given as arrays/vectors, using a syntax like [Java](https://www.w3schools.com/java/java_arrays.asp). The following expression will calculate the determinant (`DET`) of a matrix composed of 3 vectors with 3 elements each:
96-
97-
`DET({{(sin(atn(1)*2)); 0; 0}; {0; 2; 0}; {0; 0; 3}})`
98-
99-
If the user needs to evaluate a function that accepts more than one argument, including more than one array, all arrays arguments must be passed surrounded by parentheses "({...})". For example, a function call that emulates the SQL IN statement using an array argument and a reference value can be written as follows.
100-
101-
`IN_(({{(sin(atn(1)*2)); 2; 3; 4; 5}});1)`
102-
103-
The above will pass this array of strings to the `IN_` function:
97+
VBA expressions can evaluate matrix functions whose arguments are given as arrays/vectors, using a syntax like [Java](https://www.w3schools.com/java/java_arrays.asp). The following expression will calculate, and format to percentage, the internal rate of return (`IRR`) of a cash flow described using a one dimensional array with 5 entries:
10498

105-
`[{{1;2;3;4;5}}] [1]`
99+
`FORMAT(IRR({{-70000;12000;15000;18000;21000}});'Percent')`
106100

107-
However, matrix functions need to take care of creating arrays from a string, the ArrayFromString method can be used for this purpose.
101+
However, user-defined array functions need to take care of creating arrays from a string, the `ArrayFromString` method can be used for this purpose.
108102

109103
As an illustration, the `UDFunctions.cls` module has an implementation of the `DET` function with an example of using the array handle function. In addition, the `GCD` function is implemented as a demo.
110104

@@ -143,8 +137,8 @@ Sub EarlyVariableAssignment()
143137
If .ReadyToEval Then
144138
Debug.Print "Variables: "; .CurrentVariables
145139
.VarValue("Pi.e") = 1
146-
.VarValue("Pie.1") = 2
147-
.VarValue("Pie") = 3
140+
.ImplicitVarValue("Pie.1") = "2*Pi.e"
141+
.ImplicitVarValue("Pie") = "Pie.1/3"
148142
.Eval
149143
Debug.Print .Expression; " = "; .Result; _
150144
"; for: "; .CurrentVarValues
@@ -162,22 +156,22 @@ Sub TrigFunctions()
162156
End If
163157
End With
164158
End Sub
165-
Sub StringComp()
159+
Sub StringFunctions()
166160
Dim Evaluator As VBAexpressions
167161
Set Evaluator = New VBAexpressions
168162
169163
With Evaluator
170-
.Create "Region = 'Central America'" 'Create a expression with `Region` as variable
171-
.Eval ("Region = 'Asia'") 'Assign value to variable and then evaluate
164+
.Create "CONCAT(CHOOSE(1;x;'2nd';'3th';'4th';'5th');'Element';'selected';'/')"
165+
.Eval ("x='1st'")
172166
End With
173167
End Sub
174-
Sub CompareUsingLikeOperator()
168+
Sub LogicalFunctions()
175169
Dim Evaluator As VBAexpressions
176170
Set Evaluator = New VBAexpressions
177171
178172
With Evaluator
179-
.Create "Region $ 'C?????? *a'" 'Create using the LIKE operator ($) and with `Region` as variable
180-
.Eval("Region = 'Central America'") 'This will be evaluated to TRUE
173+
.Create "IFF(x > y & x > 0; x; y)"
174+
.Eval("x=70;y=15") 'This will be evaluated to 70
181175
End With
182176
End Sub
183177
```

0 commit comments

Comments
 (0)