Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubberduck203/VBEX
VBA Extension Library
https://github.com/rubberduck203/VBEX
enumerable vba vba-library vbide
Last synced: 8 days ago
JSON representation
VBA Extension Library
- Host: GitHub
- URL: https://github.com/rubberduck203/VBEX
- Owner: rubberduck203
- License: gpl-3.0
- Archived: true
- Created: 2014-09-14T23:59:00.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-27T19:09:06.000Z (over 8 years ago)
- Last Synced: 2024-08-13T07:18:26.788Z (4 months ago)
- Topics: enumerable, vba, vba-library, vbide
- Language: Visual Basic
- Size: 479 KB
- Stars: 96
- Watchers: 27
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - rubberduck203/VBEX - VBA Extension Library (Visual Basic)
README
VBEX
====_VBA Extension Library_
Intro
-----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:
1. Use Class Constructors for immutable classes.
1. Print meaningful debug methods that reveal a datastructures contentsConsole.PrintLine List.Create(1, 2, 3, 4) ' Note usage of class constructors
List(1, 2, 3, 4)1. 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.
1. Access a growing library of Containers.
1. Perform file-system operations.
- These will later be replaced or enhanced with an object-oriented model
1. Later there will be APIs for ADODB (SQL) and Windows Scripting Host
2. ADODB/SQL implemented with `SqlConnection`, `SqlCommand`, and `SqlResult`!Install
-------Once you acquire the source by either cloning this repo or downloading zip and extracting
1. Run the _Make.ps1_ script to build _VBEXsrc.xlam_ and _VBEXtest.xlam_.
- _VBEXtest.xlam_ contains unit-testing code and is only relevant to development.
1. Reference _VBEXsrc.xlam_ in projects to use VBEX
- From the VBE from the menu _tools >> References >> Browse_.
1. Enable ["Programmatic access to Office VBA project"](https://support.microsoft.com/en-us/kb/282830)
- This is required for the Lambda class as it auto-generates code in a blank module.Usage
-----VBEX is not a normal VBA library, before you start using you should understand the following aspects about VBEX.
### Predeclared Objects
All public classes have a predeclared instance of that class called the "predeclared object".
- The predeclared object has the same name as the class, _e.g._```
Dim xs As List ' word "List" as a type
Set xs = List.Create(1, 2, 3) ' word "List" here is the predeclared object
```- All creatable classes are created from the predeclared object.
- Predeclared objects of mutable classes can be mutated, but there is no reason for one to ever do so.### Inheritance
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 BooleanSetLike_IsSubSetOf = IsSubSetOf(other)
End Function
This screams for some macro or preprocessing system, but that doesn't exist yet.
### Applicable
Implementations of the _Applicable_ interface allow methods and functions to be treated as objects.
- All Applicable objects are immutable.
- The _Lambda_ class writes functions to a VBEX modules and allows you to execute that code.
+ Using the Lambda class will sometimes disable the debugger.
+ A lambda has no reference to environment in it was created.
* `Lambda.FromShort("_ + x")` will always error even if `x` is in the current scope.
- _OnArgs_ and _OnObject_ are complementary.
+ `OnArgs.Make(myObject, "method", vbMethod)` is `(x) => myObject.method(x)`
+ `OnObject.Make("method", vbMethod, myArgs)` is `(o) => o.method(myArgs)`
+ These are the _only_ applicable objects that have references to the current environment.