vb6-trace-patternlisted
Install: claude install-skill alexcassol/claude-vb6-skills
# VB6 Trace Pattern
VB6 has no native call stack accessible to user code. When an error fires in
production, `Err.Description` tells you **what** but not **where** in the
chain of calls. This pattern solves that by maintaining a manual stack in a
module-level array, pushed by `EnterMethod` on entry and popped by
`ExitMethod` on exit.
The pattern is one of the most useful additions you can make to a long-lived
VB6 codebase. The cost is one line at the top and one line in each exit path
of every instrumented procedure.
## 1. When to instrument
**Every non-trivial new procedure** gets `EnterMethod`/`ExitMethod`. "Non-trivial"
means any of:
- More than ~5 lines of logic
- Has `On Error GoTo` (CSEH style)
- Accesses database, file, or network
- Called from more than one place
**Skip** for:
- Trivial getters/setters (Property Get/Let that just reads/assigns a field)
- One-line utility functions
- Stateless pure helpers (string formatting, math)
When in doubt, instrument. The overhead is negligible compared to the
diagnostic value when something fails in production.
## 2. Canonical placement
The pattern is paired with the CSEH error-handling pattern:
```vb
'CSEH: ErrRaise
Public Function GetActiveCustomer(ByVal lngCustomerID As Long) As Object
'<EhHeader>
On Error GoTo GetActiveCustomer_Err
EnterMethod "modDB", "GetActiveCustomer"
'</EhHeader>
' ... body ...
'<EhFooter>
On Error GoTo 0
GetActiveCustomer_Exit: