twinBASIC Update: September 26, 2021

Highlights include a sneak peek at building custom form controls, the related dynamic property sheet, and a bunch of screenshots teasing the upcoming features.

twinBASIC Update: September 26, 2021

On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference.  I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025.  With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.

Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project.  If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.


Highlights

GUI / Form Designer Sneak Peek

Wayne published an update on the GUI progress.

At this point, there are no built-in controls.  Instead, there are custom controls that are built up from twinBASIC classes.  

In practice, I don't anticipate most tB users will be creating their own custom controls.  However, this feature will allow for the tB community to develop and share their custom control classes.  In turn, I would expect many tB users will be importing custom controls from forums and websites.

Button samples

The screenshot below is taken from the form designer.  Each button is a different instance of a single custom control class written in twinBASIC.  

The variations are all based on the respective property values.  The Property Sheet should look familiar.  I assume that the properties listed are all dynamic: when the underlying twinBASIC class changes, the Property Sheet would update accordingly.

Here is an excerpt from the underlying class, WaynesButton:

Notice how the public properties in the class module (beginning at line 183), correspond to properties in the property sheet in the previous screenshot.  

Also, the NormalState property is a custom object based on a private class, ButtonState.  The public properties of the ButtonState class appear on the Property Sheet as a collapsible tree underneath the NormalState property.  Very cool!

There are additional screenshots and explanation on the Github issue page.  Be sure to check it out!

Around the Web

Embedding Structured Resources

Ben Clothier suggested adding support for a structure-based table when embedding resources in twinBASIC.

Embedded resources in VB6 are little more than a table of strings (embedded resources are not really a thing in VBA).  This approach limits its usefulness.

A structure-based option would provide type safety and enforce consistency better than the current table-of-strings approach.  

Ben offers two examples that would benefit from this feature:

  • Custom errors
  • Custom messages

The custom errors example is one that I find particularly compelling.  I tried maintaining a custom error enumeration in VBA years ago, but I quickly abandoned it because it was so unwieldy.  I eventually wrote a routine to simplify throwing custom errors in VBA.  

Design-time Typelib Generation

Ben Clothier requested a feature where developers could create components that would dynamically expose new members based on user design changes.  

(Ben was busy this week.  He also started a discussion about custom serialization, primarily as it pertains to custom control classes.)

An example of this would be adding a label to an Access form and naming it MyLabel.  Then, in the form's code-behind, you could address the label using the syntax Me.MyLabel.  

Ben suggested that the feature could be used to develop an Object-Relational Mapping (ORM) framework with compile-time error checking.  That is indeed an intriguing use case.

Changelog

Here are the updates from the past week.  You can also find this information by installing the twinBASIC VS Code extension and clicking on the Changelog tab of the extension page:

Nothing to see here this week!

All original code samples by Mike Wolfe are licensed under CC BY 4.0