You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-22Lines changed: 16 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,17 @@
2
2
[](https://github.com/ws-garcia/VBA-Expressions/blob/master/LICENSE)[](https://github.com/ws-garcia/VBA-Expressions/releases/latest)
3
3
4
4
## 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.
*__Very flexible and powerful__: variables, constants and user-defined functions (UDFs) support.
14
16
*__Implied multiplication for variables, constants and functions__: `5avg(2;abs(-3-7tan(5));9)` is valid expression; `5(2)` is not.
15
17
*__Evaluation of arrays of expressions given as text strings, as in Java__: curly brackets must be used to define arrays`{{...};{...}}`
16
18
*__Floating point notation input support__: `-5E-5`, `(1.434E3+1000)*2/3.235E-5` are valid inputs.
@@ -92,19 +94,11 @@ Sub AddingNewFunctions()
92
94
End Sub
93
95
```
94
96
## 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_multi.asp). The following expression will calculate the determinant (`DET`) of a matrix composed of 3 vectors with 3 elements each:
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:
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.
108
102
109
103
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.
110
104
@@ -143,8 +137,8 @@ Sub EarlyVariableAssignment()
143
137
If .ReadyToEval Then
144
138
Debug.Print "Variables: "; .CurrentVariables
145
139
.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"
148
142
.Eval
149
143
Debug.Print .Expression; " = "; .Result; _
150
144
"; for: "; .CurrentVarValues
@@ -162,22 +156,22 @@ Sub TrigFunctions()
162
156
End If
163
157
End With
164
158
End Sub
165
-
Sub StringComp()
159
+
Sub StringFunctions()
166
160
Dim Evaluator As VBAexpressions
167
161
Set Evaluator = New VBAexpressions
168
162
169
163
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
0 commit comments