McBasic™Get McBasic™ ↗
Build 881
Component SDK 1.0

Author BASIC libraries and controls

Design a reusable public API and test it from a separate consumer.

Export behavior from a standard module#

Create a Library project and keep calculation code independent of Forms. Public members are the consumer API; Private helpers are not exported. Give the package an identity, semantic version, vendor and license metadata before building it.

A complete minimal module with a certification self-test
Option Explicit

Public Function AddCurrency(ByVal amount As Currency, ByVal increment As Currency) As Currency
    AddCurrency = amount + increment
End Function

Public Function McBasicPluginSelfTest() As Boolean
    McBasicPluginSelfTest = AddCurrency(CCur(2), CCur(3)) = CCur(5)
End Function

The self-test is required for library certification. A successful self-test is one gate, not a claim of full certification. The MoneyTools lesson includes the rest of the project contract.

Compose a visual control#

Create a UserControlLibrary and design its internal children. Write public property accessors that translate the consumer’s values into internal state. Raise a public event for an action the consumer should decide how to handle.

Requires the CustomerCard layout and its txtName / cmdOpen children
Public Event OpenRequested()

Public Property Get CustomerName() As String
    CustomerName = txtName.Text
End Property

Public Property Let CustomerName(ByVal value As String)
    txtName.Text = value
End Property

Private Sub cmdOpen_Click()
    RaiseEvent OpenRequested
End Sub

Use the complete CustomerCard project for both controls, exact layouts, event bindings and all code.

Test from the outside#

Build the package and resolve it in a separate application. Set the public properties, attach the exported event and verify two instances do not share state accidentally. Do not include the authoring source in the consumer to make it compile; that would bypass the package boundary you need to test.

Protect consumers when changing the control#

  • Keep component ID and public names stable for compatible releases.
  • Preserve property defaults or document the behavior change.
  • Test old saved layouts against the new version.
  • Check the event contract and runtime behavior, not only the Toolbox preview.
  • Compare package contents from repeated builds before distributing.
Source baseline 20f4bfed6b · Build manifest