← ClaudeAtlas

vb6-trace-patternlisted

Applies the manual stack-trace pattern for Visual Basic 6 based on EnterMethod/ExitMethod calls that push and pop method names from a module-level array. This pattern compensates for the absence of a native call stack in VB6, enabling rich production logs with call depth, parameter serialization, and on-demand stack inspection in error handlers. Covers when to instrument procedures (every non-trivial function), placement rules (EnterMethod in EhHeader, ExitMethod in both success and error paths), optional parameter serialization, the TraceMethod function for inserting the current stack into error messages, log file management (rolling daily logs with retention), activation gating (only logs when explicitly enabled or running in the IDE), and automatic process dumping via WMI when automation errors are detected. Activates whenever working with EnterMethod, ExitMethod, LogMsg, TraceMethod, manual stack trace, or any VB6 task involving production diagnostics, error logging, debugging, or fault investigation.
alexcassol/claude-vb6-skills · ★ 0 · AI & Automation · score 70
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: