vb6runtime
VB6 runtime library providing value system, type conversions, and standard library implementations.
Overview
vb6runtime provides the runtime execution infrastructure for VB6 programs. It is used by both vb6interpret (for direct execution) and vb6compile (for linking compiled output with runtime support). This crate contains everything needed to execute VB6 code at runtime, but not the compilation/IR infrastructure.
Architecture
┌─────────────────┐ ┌─────────────────┐
│ vb6interpret │ │ vb6compile │
└────────┬────────┘ └────────┬────────┘
│ │
└───────────┬───────────────┘
│
┌──────▼───────┐
│ vb6runtime │
└──────┬───────┘
│
┌──────▼───────┐
│ vb6semantic │
└──────────────┘
│
┌──────▼───────┐
│ vb6parse │
└──────────────┘
Note: vb6core contains the foundational VB6 type definitions (VBType, VBError), while vb6runtime provides the execution infrastructure on top of them.
Core Components
1. Value System
Runtime representation of all VB6 values:
2. Shared Type System
The runtime crate uses the shared type model from vb6core instead of maintaining a second copy of the VB6 type definitions. Runtime code consumes VBType, TypeInfo, ArrayBound, VBError, and VBResult from vb6core, while vb6runtime adds the dynamic value layer (VBVariant, ArrayValue, and conversion behavior):
use ;
use ;
3. Type Conversions
VB6-exact conversion rules:
- Widening conversions (Byte → Integer → Long → Double → Variant)
- String to number parsing
- Boolean representations (True = -1, False = 0)
- Variant unwrapping
- Null propagation
4. Argument Handling Model
VB6 procedures do not pass arguments as a bare list of values. The runtime should model an invocation as a structured call context so it can preserve semantics for omitted arguments, ByRef/ByVal, and ParamArray handling.
This model keeps VBVariant focused on data representation while letting the runtime distinguish:
- omitted optional arguments
ByRefversusByValsemantics- variable-length argument lists for
ParamArray - VB6-specific cases such as
Empty,Null, andMissing
In practice, a call flow evaluates each argument expression into a VBVariant, wraps it in a call context, binds it to the formal parameter list, and then dispatches to the appropriate procedure implementation.
5. Standard Library
Full implementations of VB6 built-in functions are in vb6runtime::library::.
See vb6runtime library docs for the complete function reference.
6. Runtime State
Process-global state (environment snapshot, RNG seed, settings store) lives in vb6runtime::state::.
Features
Value Operations
- Arithmetic with proper type promotion
- String concatenation
- Comparison operators
- Variant coercion
Array Support
- Dynamic arrays with ReDim
- Preserve semantics
- Multi-dimensional arrays
- Custom bounds (arrays starting at any index)
Type Safety
- VB6-exact conversion rules
- Null and Empty handling
- Error value propagation
- Variant type checking
Usage
Creating Values
use VBVariant;
let num = from_integer;
let text = from_string;
Type Conversion
VB6 runtime provides TryFrom<&VBVariant> implementations on typed wrappers for VB6-exact conversion:
use VBVariant;
let value = from_string;
let long_val: VBLong = value.try_into.unwrap;
assert_eq!;
Library Functions
VB6 library functions are in vb6runtime::library:::
use string;
let result = left; // "Hello"
Known Limitations
- FRX resource file handling is limited: binary blobs are loaded but not all are mapped to control properties.
- The runtime does not yet support VB6 class modules or COM object integration.
Dependencies
thiserror- Error handlingserde- Serialization supportnum-traits- Numeric operationsjiff- Date/time operationsencoding_rs- String encoding
Testing
# Run all tests
# Run with output
# Run benchmarks
Status
✅ Active Development — Core value system, type conversions, and 50+ library functions are implemented. See DESIGN.md for detailed design documentation.
See Also
- Parameter Classification — How library function parameters are classified for conversion
License
MIT License - See LICENSE file for details.