twinBASIC Update: May 22, 2022

Highlights include the beginnings of a Screen object, an updated Attribute syntax, and a reimagined ending to a Disney classic (yes, it's a bit off-topic).

twinBASIC Update: May 22, 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:


Screen Object Added

The Screen object from VB6 is now available in limited form within twinBASIC.  Currently, it only supports the following properties/methods:

  • Fonts
  • FontCount

Bug Fixes

There were several noteworthy bug fixes, both in the IDE and the language itself, including:

  • Save Project dialog now warns if you are about to overwrite an existing project file
  • Setting breakpoints is now more reliable
  • Date$ and Time$ now return the correct invariant formats (MM-DD-YYYY and HH:NN:SS)

In reading through the GitHub issues, it's clear that user @KarlSevenSeven is working on converting a large VB6 project to run in twinBASIC.  He's uncovered several edge and corner cases that Wayne has been playing Whac-A-Mole with this past week.

Every bug fixed is one step closer to 100% backward compatibility.

Around the Web

Updated Attribute Syntax

The current attribute syntax (e.g., [ Description ("this does foo") ]) is being deprecated in favor of a different syntax that addresses a few shortcomings of the original, namely:

  • Square brackets already have multiple meanings in VBx
  • Awkward syntax for inline attributes
  • Incompatible with enum members (this alone was probably a deal-breaker for the original syntax)

The new syntax is: @Description("this does foo")

  • @: the literal "at" character
  • Description: the attribute name
  • ("this does foo"): attribute arguments (optional for boolean attributes)

You can read Wayne's announcement on Github.

Procedure Execution Order Differs Between Native (Compiled) Code and (intermediate language) P-Code

While Wayne has not yet devised a solution to this problem, I found its mere existence to be rather unexpected:

So in VB6, with the following code you will see different ordering of the execution of procedures depending on whether you compile to Native Code or PCode.
Module MyModule

    Public g_Log As String

    Public Sub Test()
        Dim LHS As New MyClass
        Dim RHS As New MyClass2
        Set LHS.Target = RHS.Clone
        MsgBox g_Log
    End Sub

End Module

Class MyClass

    Public Sub Class_Initialize()
        g_Log = g_Log & vbCrLf & "MyClass.Class_Initialize was called"
    End Sub

    Public Property Set Target(ByVal Value As MyClass2)
        g_Log = g_Log & vbCrLf & "MyClass.Target was called"
    End Property

End Class

Class MyClass2
    Public Sub Class_Initialize()
        g_Log = g_Log & vbCrLf & "MyClass2.Class_Initialize was called"
    End Sub

    Public Function Clone() As MyClass2
        g_Log = g_Log & vbCrLf & "MyClass2.Clone was called"
    End Function

End Class

Wayne ends with the following thought:

Unfortunately, for ultimate compatibility, we're probably going to need a switch to simulate the different compilation behaviours. 😢

Tangents and Rabbit Holes

This item is just a bit off-topic...

Did anyone ever point out a misstatement you made and–instead of acknowledging said mistake and moving on–you invented an alternate ending for an 85-year-old beloved children's movie which you then tied in to a completely unrelated cult classic movie released 62 years later? neither.

Unless you count my response to Ben Clothier's comment from last week's twinBASIC update:

Can you please walk me through the scene where Ms. White hustled a cottage from the seven dwarves? I seemed to have missed that scene.


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 46 is now available:

  • fixed: a form class being declared as Private causes linkage errors (runtime messages of 9508/9402) [ execution works in IDE, not from VBA #864 ]
  • fixed: panels in the bottom vertical section shouldn't have collapse/expand toggle icons [ IDE -- BETA RELEASE #772#issuecomment-1133589694 ]
  • 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


BETA 45 is now available:


BETA 44 is now available:


BETA 43 is now available:

  • fixed: Rnd() initial seed was not being set in built EXE/DLL files [ problem #856 ]
  • improved: global variables code-gen errors are to be ignored until the global variables get initialized [ error messages in debug console #852 ]
  • fixed: global initializers/terminators not being executed in DLL builds [ jpbro ]


BETA 42 is now available:

  • fixed: passing an object-type array element to a ByRef parameter with an inexact matching type (e.g. Object/Variant), caused an array lock to be left open [ Preserve: Memory is locked #855 ]
  • top-level menu disappears when moving back to the top-level menu header [ IDE -- BETA RELEASE #772#issuecomment-1130158068 ]


BETA 41 is now available:


BETA 40 is now available:

  • fixed: statements entered between an opening Select Case and before the first Case statement are now not allowed [ executes code between Select Case and first case statement #844 ]
  • added: Global.LoadResIdList(resourceType) function, returning an array of names/ids contained within a resource folder, see examples in WebView2 samples (CopyResourcesFolderContentsToLocalPath function)
  • added: Screen object, currently only offering Fonts, and FontCount member
  • fixed: IDE menu clicks vs mousedown/up behaviour [ IDE -- BETA RELEASE #772#issuecomment-1127692147 ]

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