Table of Contents

3.4.2 Simple Statements

Each simple statement is cross-referenced below to its section of MS-VBAL §5.4.2 Control Statements, MS-VBAL §5.4.3 Data Manipulation Statements or MS-VBAL §5.4.4 Error Handling Statements, and to the RD-VBAL page that describes its implementation.

Statement Node type MS-VBAL RD-VBAL
Call / bare call CallStatementNode MS-VBAL §5.4.2.1 Call Statement RD-VBAL §5.4.2.1 Call Statement
Let assignment ([Let] lExpression = expression) AssignmentStatementNode (Kind: ImplicitLet or ExplicitLet) MS-VBAL §5.4.3.8 Let Statement RD-VBAL §5.4.3.8 Let Statement
Set assignment AssignmentStatementNode (Kind: Set) MS-VBAL §5.4.3.9 Set Statement RD-VBAL §5.4.3.9 Set Statement
LSet AssignmentStatementNode (Kind: LSet) MS-VBAL §5.4.3.6 LSet Statement RD-VBAL §5.4.3.6 LSet Statement
RSet AssignmentStatementNode (Kind: RSet) MS-VBAL §5.4.3.7 RSet Statement RD-VBAL §5.4.3.7 RSet Statement
Mid, Mid$, MidB, MidB$ MidStatementNode; see Mid Statement MS-VBAL §5.4.3.5 Mid/MidB/Mid$/MidB$ Statement RD-VBAL §5.4.3.5 Mid/MidB/Mid$/MidB$ Statement
ReDim, ReDim Preserve RedimDeclarationNode; see ReDim Statement MS-VBAL §5.4.3.3 ReDim Statement RD-VBAL §5.4.3.3 ReDim Statement
Erase KeywordStatementNode (Token: Erase) MS-VBAL §5.4.3.4 Erase Statement RD-VBAL §5.4.3.4 Erase Statement
Name...As KeywordStatementNode (Token: Name) None None
RaiseEvent KeywordStatementNode (Token: RaiseEvent) MS-VBAL §5.4.2.20 RaiseEvent Statement RD-VBAL §5.4.2.20 RaiseEvent Statement
Stop KeywordStatementNode (Token: Stop) MS-VBAL §5.4.2.11 Stop Statement RD-VBAL §5.4.2.11 Stop Statement
End KeywordStatementNode (Token: End) MS-VBAL §5.4.2.22 End Statement RD-VBAL §5.4.2.22 End Statement
Exit Do KeywordStatementNode (Token: "Exit Do") MS-VBAL §5.4.2.7 Exit Do Statement RD-VBAL §5.4.2.7 Exit Do Statement
Exit For KeywordStatementNode (Token: "Exit For") MS-VBAL §5.4.2.5 Exit For Statement RD-VBAL §5.4.2.5 Exit For Statement
Exit Sub KeywordStatementNode (Token: "Exit Sub") MS-VBAL §5.4.2.17 Exit Sub Statement RD-VBAL §5.4.2.17 Exit Sub Statement
Exit Function KeywordStatementNode (Token: "Exit Function") MS-VBAL §5.4.2.18 Exit Function Statement RD-VBAL §5.4.2.18 Exit Function Statement
Exit Property KeywordStatementNode (Token: "Exit Property") MS-VBAL §5.4.2.19 Exit Property Statement RD-VBAL §5.4.2.19 Exit Property Statement
GoTo GoToStatementNode MS-VBAL §5.4.2.12 GoTo Statement RD-VBAL §5.4.2.12 GoTo Statement
GoSub GoSubStatementNode MS-VBAL §5.4.2.14 GoSub Statement RD-VBAL §5.4.2.14 GoSub Statement
On expression GoTo label, ... OnGoToStatementNode MS-VBAL §5.4.2.13 On...GoTo Statement RD-VBAL §5.4.2.13 On...GoTo Statement
On expression GoSub label, ... OnGoSubStatementNode MS-VBAL §5.4.2.16 On...GoSub Statement RD-VBAL §5.4.2.16 On...GoSub Statement
Return ReturnStatementNode MS-VBAL §5.4.2.15 Return Statement RD-VBAL §5.4.2.15 Return Statement
On Error GoTo <label> OnErrorGoToStatementNode MS-VBAL §5.4.4.1 On Error Statement RD-VBAL §5.4.4.1 On Error Statement
On Error Resume Next OnErrorResumeStatementNode MS-VBAL §5.4.4.1 RD-VBAL §5.4.4.1 On Error Statement
Bare Resume, Resume <label> ResumeStatementNode (LabelExpression nullable) MS-VBAL §5.4.4.2 Resume Statement RD-VBAL §5.4.4.2 Resume Statement
Resume Next ResumeNextStatementNode MS-VBAL §5.4.4.2 RD-VBAL §5.4.4.2 Resume Statement
Error <number> ErrorStatementNode MS-VBAL §5.4.4.3 Error Statement RD-VBAL §5.4.4.3 Error Statement

Name...As is not an MS-VBAL-numbered statement: MS-VBAL has no section for it.

Assignment Statements

Let, Set, LSet and RSet share one node type, AssignmentStatementNode, distinguished by its AssignmentKind Kind. LSet and RSet have the same node shape as Let and Set.

The Target of an AssignmentStatementNode is always an lExpression. It draws from the shared expression family described in RD-VBAL §3.0.2 Node Types: a member access, an index, a dictionary access, or a bare name.

The runtime semantics of LSet and RSet are described in RD-VBAL §5.4.3.6 LSet Statement and RD-VBAL §5.4.3.7 RSet Statement.

Mid Statement

MidStatementNode records the statement's spelling in two independent flags. IsByteMode distinguishes MidB/MidB$ from Mid/Mid$; IsStringInput records the $ suffix.

Spelling IsByteMode IsStringInput
Mid false false
Mid$ false true
MidB true false
MidB$ true true

The replacement-span mechanics of MS-VBAL §5.4.3.5 split only on byte mode (MidB/MidB$ versus Mid/Mid$), never on the $ suffix. IsStringInput is preserved because it mirrors the VBVariant/VBString split of the Mid/Mid$ function overloads, which matters for static semantics.

ReDim Statement

ReDim and ReDim Preserve are represented by RedimDeclarationNode. ReDim is modelled as a declaration node, not a statement node, because it declares or resizes storage.

Branching Statements

Statement labels and line numbers are captured as separate nodes, LineLabelNode and LineNumberNode; see RD-VBAL §5.4.1.1 Statement Labels.

A GoTo or GoSub statement's target is an expression naming or numbering a label or line. There is no static link between the GoToStatementNode or GoSubStatementNode and the LineLabelNode or LineNumberNode it targets.

OnGoToStatementNode and OnGoSubStatementNode hold their targets in a Labels list. They follow the same convention as GoTo and GoSub: each target is an expression naming or numbering a label or line, with no static link to the label node.

OnGoToStatementNode and OnGoSubStatementNode are separate node types rather than one shared node with a Kind. This mirrors the separate GoToStatementNode and GoSubStatementNode, because GoTo and GoSub are distinct branch mechanisms. By contrast, Let, Set, LSet and RSet share one node type, AssignmentStatementNode, distinguished by Kind.

Error-Handling Statements

On Error Resume Next and On Error GoTo are parsed by the same grammar rule, disambiguated by the keyword that follows On Error.

The SDK documentation of OnErrorGoToStatementNode also covers the On Error GoTo -1 form, which MS-VBAL does not document; see RD-VBAL §5.4.4.1 On Error Statement.

ResumeStatementNode.LabelExpression is nullable: a bare Resume has no label.

Resume Next has its own node type, ResumeNextStatementNode. It is not a ResumeStatementNode with a "Next" label.


⏮️ RD-VBAL §3.4.1 Block Statements | ⏭️ RD-VBAL §3.4.3 File Statements