Introduction
This guide will walk you through using VB6Parse, from installation to advanced parsing scenarios. By the end, you'll understand how to parse VB6 projects, handle errors, navigate syntax trees, and build tools that process legacy Visual Basic 6 code.
Prerequisites
- Rust: Version 1.70 or later (Install from rustup.rs)
- Basic Rust knowledge: Understanding of Result types, ownership, and cargo
- VB6 familiarity: Helpful but not required
Installation
Create a new Rust project
cargo new vb6parse-demo
cd vb6parse-demo
Add VB6Parse to Cargo.toml
[dependencies]
vb6parse = "0.5.1"
Verify installation
cargo build
Your First Parse: Hello World
Let's start with the simplest possible example - parsing a VB6 module with a single subroutine.
Create a simple module parser
Replace the contents of src/main.rs:
Loading example from GitHub...
Run the example
cargo run
VB6Parse uses a
ParseResult<T, E> type that contains both the parsed output
(Option<T>) and any failures (Vec<ErrorDetails<E>>).
This allows partial success - you can get a usable parse tree even if some parts failed.
Parsing VB6 Projects
VB6 projects (.vbp files) list all modules, forms, and references. Let's parse one:
Loading example from GitHub...
Handling Parse Errors
VB6Parse is designed to handle malformed input gracefully. Even with syntax errors, you often get partial results:
Loading example from GitHub...
Tokenization
For lower-level analysis, you can tokenize VB6 code without building a full parse tree:
Loading example from GitHub...
Parsing Forms and Controls
Forms are the most complex VB6 file type, containing both UI controls and code:
Loading example from GitHub...
Common Use Cases
Here are some practical applications you can build with VB6Parse:
Code Migration Tools
Parse VB6 projects and convert them to modern languages (C#, VB.NET, Python). Extract forms, business logic, and database connections for automated conversion.
Static Analysis
Build linters and code quality tools for legacy VB6 codebases. Find deprecated API usage, detect code smells, enforce coding standards.
Documentation Generation
Automatically generate API documentation from VB6 source code. Extract function signatures, comments, and module relationships.
Code Metrics
Calculate lines of code, cyclomatic complexity, dependency graphs, and other metrics for project planning and technical debt assessment.
Form Extraction
Extract UI layouts and control hierarchies from .frm files for migration to modern UI frameworks or for visual documentation.
Code Search Tools
Build semantic search tools that understand VB6 syntax. Find all usages of a function, locate API calls, track variable usage across projects.
Next Steps
Now that you understand the basics, explore these resources:
📖 API Documentation
Complete API reference with all types, methods, and examples
💡 Code Examples
More examples showing advanced parsing scenarios and techniques
📚 Technical Documentation
Deep dive into VB6 file formats and parser architecture
• Check the GitHub Issues for common problems
• Review the examples directory for more code samples
• Open a discussion or issue if you encounter problems