VBA Extension Library
VBA Extension Library
Ease production of VBA code with the VBEX library of rich idiomatic containers and some functional programing capabilities to bring VBA into the new millenium. With VBEX you can:
Use Class Constructors for immutable classes.
Print meaningful debug methods that reveal a datastructures contents
Console.PrintLine List.Create(1, 2, 3, 4) ' Note usage of class constructors List(1, 2, 3, 4)
Create functional objects to use with higher order functions. With those we have created some monadic classes (List, Maybe, Try) that implement the traditonal Map
, FlatMap
or Bind
methods.
Access a growing library of Containers.
Perform file-system operations.
Later there will be APIs for ADODB (SQL) and Windows Scripting Host
2. ADODB/SQL implemented with SqlConnection
, SqlCommand
, and SqlResult
!
Once you acquire the source by either cloning this repo or downloading zip and extracting
VBEX is not a normal VBA library, before you start using you should understand the following aspects about VBEX.
All public classes have a predeclared instance of that class called the "predeclared object".
Dim xs As List ' word "List" as a type
Set xs = List.Create(1, 2, 3) ' word "List" here is the predeclared object
Since VBA has only Interface Inheritance,
code that would be put in parent or abstract classesis instead put into def*
modules.
While this reduces code duplication, it only reduces it to trivial code like,
Public Function IsSubSetOf(ByVal other As SetLike) As Boolean
IsSubSetOf = defSetLike.IsSubSetOf(Me, other)
End Function
Private Function SetLike_IsSubSetOf(ByVal other As SetLike) As Boolean
SetLike_IsSubSetOf = IsSubSetOf(other)
End Function
This screams for some macro or preprocessing system, but that doesn't exist yet.
Implementations of the Applicable interface allow methods and functions to be treated as objects.
Lambda.FromShort("_ + x")
will always error even if x
is in the current scope.OnArgs.Make(myObject, "method", vbMethod)
is (x) => myObject.method(x)
OnObject.Make("method", vbMethod, myArgs)
is (o) => o.method(myArgs)