twinBASIC Update: May 29, 2022

Highlights include new build features, a good Exit Code discussion, and a multi-threaded twinBASIC proof of concept from Ben Clothier.

twinBASIC Update: May 29, 2022

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.

Here are some links to get involved with the project:


Command Line Arguments Support in New IDE

Support for command line arguments when debugging was added in BETA 49 of the new twinBASIC IDE.  Here's Wayne's announcement:

[T]his used to be in the build-configuration settings in the VS code version, but we don't have the equivalent of that in the new IDE.  Let's just move it to the project Settings.

RunAfterBuild Changed From Project Setting to Attribute

The "Run After Build" project setting has been removed.  In its place is a more flexible [ RunAfterBuild ] attribute (attributes are still using the square bracket syntax for now, but at some point will be replaced with the "@" syntax; e.g., @RunAfterBuild.

Here's Wayne's announcement:

In BETA 49 the project setting of Run After Build has now been removed. As discussed, we've now got a much more flexible [ RunAfterBuild ] attribute that can be applied to a procedure in a standard module, like so:

[ RunAfterBuild ]
Private Sub BuildScript()
    Shell App.LastBuildPath
End Sub

App.LastBuildPath is also new, and populated immediately after the build completes (and before BuildScript runs). The new auto-increment version feature (#854) only kicks in after your build script completes (so that the App object version numbers are valid according to the just built executable).

If you just want to open the build output folder in Windows Explorer, you can use something like this:

[ RunAfterBuild ]
Private Sub BuildScript()
    Dim buildFolder As String = Left$(App.LastBuildPath, InStrRev(App.LastBuildPath, "\"))
    Shell "explorer """ & buildFolder & """", vbNormalFocus
End Sub

New Project Versioning Options

In an effort to better support both semantic versioning and continuous integration (CI) build pipelines, Wayne added several new features around application versioning.

Here's the announcement:

In BETA 49:

  • fixed: corrected the VERSIONINFO Build/Revision ordering The output should have its version available
  • added: project setting 'project.versionAutoIncrement' (None|Revision|Build|Minor|Major, and auto import from VBP)
  • added: buildPath/exportPath placeholders: ${VersionMajor}, ${VersionMinor}, ${VersionBuild}, ${VersionRevision}

Around the Web

Specifying an Exit Code from a twinBASIC Executable

Github user Greedquest opened this issue recently, and it sparked an interesting discussion:

As well as stderr, stdout, exe's also specify an exit code - 0 indicating success, non-zero indicating failure. This is a very useful standard to integrate tB into other toolchains.

Check out the link above to follow the conversation and offer your thoughts.

Multi-threading/Asynchronous Code Proof of Concept

Ben Clothier has put together a proof of concept using Win32 API calls demonstrating twinBASIC's underlying support for multi-threading.

Multithreading/asynchrony proof of concept · Discussion #867 · WaynePhillipsEA/twinbasic
VB6 and VBA normally run single-threaded and it was not well-architectured for multithreading. You could try to make new threads but it was very risky. It was common for some VB6 developers to reso...

As a reminder, twinBASIC does not yet have syntax support for multi-threading yet, but there is compiler support for the feature.  Ben's proof of concept bodes well for the multi-threading and asynchronous support that remains on the horizon (scheduled for Q4 2022 release according to the current twinBASIC roadmap).


Here are the updates from the past week.  You can also find this information by visiting the GitHub twinBASIC IDE issues page.

twinBASIC IDE -- BETA RELEASE · Issue #772 · WaynePhillipsEA/twinbasic
As discussed in #763, I've been busy working for the last few weeks on a new IDE, specifically designed for the twinBASIC compiler. Here are the details for installing the current BETA release ...

NOTE: Development of the twinBASIC VSCode extension is paused until 2023 so that efforts can be focused on the new IDE.  


BETA 50 is now available:

  • improved: reordered the Revision/Build project settings to better match the VERSIONINFO output [ ]
  • fixed: TypeName / IUnknown-extended interfaces issue [ ]
  • fixed: Form.Load event firing before the form constructor [ ]
  • added: App.PrevInstance property


BETA 49 is now available:

  • fixed: corrected the VERSIONINFO Build/Revision ordering [ ]
  • added: project setting 'project.versionAutoIncrement' (None|Revision|Build|Minor|Major, and auto import from VBP)
  • added: buildPath/exportPath placeholders: ${VersionMajor}, ${VersionMinor}, ${VersionBuild}, ${VersionRevision}
  • removed: RunAfterBuild project setting
  • added: RunAfterBuild module procedure attribute, allowing for triggering procedure execution after successful build [ ]
  • improved: runtime unhandled errors in generated EXEs/DLLs now provide the error number and description as per VBx [ ]
  • added: project setting 'Debugger: Runtime Command Line Arguments' [ ]
  • fixed: DoEvents now returns the number of open forms [ ]
  • fixed: regression with form control z-order not being reflected in the runtime form creation [ ]


BETA 48 is now available:

  • added: Screen.Width / Screen.Height (back-compat, primary screen only)
  • added: Screen.TwipsPerPixelX/Y (non-rounded, floating point value)
  • added: Screen.ActiveForm (thread aware)
  • added: Screen.ActiveControl (thread aware)
  • added: Screen.MousePointer (thread aware)
  • added: project setting 'project.versionComments' (and auto import from VBP)
  • added: project setting 'project.versionCompanyName' (and auto import from VBP)
  • added: project setting 'project.versionFileDescription' (and auto import from VBP)
  • added: project setting 'project.versionLegalCopyright' (and auto import from VBP)
  • added: project setting 'project.versionLegalTrademarks' (and auto import from VBP)
  • added: project setting 'project.versionProductName' (and auto import from VBP)
  • added: App.Comments
  • added: App.CompanyName
  • added: App.FileDescription
  • added: App.LegalCopyright
  • added: App.LegalTrademarks
  • added: App.ProductName
  • improved: generated EXEs and DLLs now include the VERSIONINFO resource, generated from the compiler settings [ ]


BETA 47 is now available:

  • fixed: static variables inside class modules being treated as if inside standard modules [ ]
  • fixed: tooltips misplaced [ ]
  • fixed: SaveProjectAs should save the open editors [ ]
  • improved: IDE is now built using the current released version of the WebView2 tB control
  • improved: IDE now detects WebView2 Runtime installation problems and prompts to install it if necessary
  • improved: WebView2 samples now specifically demonstrate how to detect when WebView2 Runtime is not installed
  • fixed: clean-build command won't create the output folder if it doesn't already exist [ ]


BETA 46 is now available:

  • fixed: a form class being declared as Private causes linkage errors (runtime messages of 9508/9402) [ ]
  • fixed: panels in the bottom vertical section shouldn't have collapse/expand toggle icons [ ]
  • improved: you can now click on empty space in a tree panel to focus the tree, allowing for keyboard entry
  • fixed: intellisense issue where the enter key would not clear the intellisense window at the end of a line following a space and no selection