# vb6-legacy

A skill for classic VB6 work: how to port code to VB.NET and call COM objects without leaking processes.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 329 installs · ★ 78
- Author: Claude MPM Team
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/visualbasic/legacy/vb6-legacy/SKILL.md
- Updated: 2026-07-18
- HTML: https://affpapa.org/en/nevibecode/skills/vb6-legacy

## What it does

The skill gathers what you would otherwise dig out of old forum threads: VB6 versus VB.NET differences, COM interop patterns, and the usual migration traps. The code samples cover `Variant` against strong typing with `Option Strict On`, `ByRef` as the default against `ByVal`, `On Error` against `Try-Catch`, and control arrays against `List(Of TextBox)`.

A separate section handles COM from VB.NET. Early binding through a type library reference, late binding through `Type.GetTypeFromProgID` with reflection calls. There is a release pattern too: `Marshal.ReleaseComObject` in reverse creation order, then `GC.Collect`. Skip it and the Excel process stays in memory, so this is worth checking if you export to Excel anywhere.

The skill also shows how to expose a .NET component to COM: `ComVisible`, `Guid` and `ProgId` attributes, an interface marked `InterfaceIsDual`, and registration with `regasm` using `/tlb` and `/codebase`. You do not invoke it yourself — the model pulls it in when VB6 or COM shows up in a task.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill vb6-legacy -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/vb6-legacy/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/vb6-legacy/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill vb6-legacy -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/vb6-legacy/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill vb6-legacy -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/vb6-legacy/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install bobmatnyc/claude-mpm-skills vb6-legacy
```

2. **Manually: put the files in place**
- File: `.github/skills/vb6-legacy/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill vb6-legacy -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/bobmatnyc/claude-mpm-skills --path toolchains/visualbasic/legacy/vb6-legacy
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/vb6-legacy/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill vb6-legacy -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/visualbasic/legacy/vb6-legacy/SKILL.md

## When to use it
- move error handling from `On Error` to `Try-Catch`
- find out why an Excel process lingers after export
- pick between early and late COM binding
- swap control arrays for collections in VB.NET
- expose a .NET class to existing COM callers

## Example prompts
- port this module from VB6 to VB.NET, start with the error handling
- why does EXCEL.EXE stay in Task Manager after my export runs
- make this class COM-visible and show me how to register it

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: b34a76fde8ae88cd.

BEGIN THIRD-PARTY FILE b34a76fde8ae88cd
````text
---
name: vb6-legacy
description: Classic VB6 patterns, COM interop, migration strategies
user-invocable: false
disable-model-invocation: true
version: 1.0.0
category: toolchain
author: Claude MPM Team
license: MIT
tags: [visualbasic, vb6, legacy, com, interop, migration]
---

# VB6 Legacy and COM Interop

Patterns for maintaining VB6 code and strategies for migrating to VB.NET with COM interop.

## VB6 to VB.NET Migration

### Key Differences

```vb
' VB6 - Variant types
Dim data As Variant
data = 123
data = "Hello"

' VB.NET - Strong typing with Option Strict On
Option Strict On
Dim data As Object  ' Still avoid when possible
Dim number As Integer = 123
Dim text As String = "Hello"

' VB6 - Default properties
Text1.Text = "Hello"
Text1 = "Hello"  ' Uses default Text property

' VB.NET - Explicit properties required
TextBox1.Text = "Hello"  ' Must be explicit

' VB6 - ByRef default
Sub ProcessData(data As String)  ' ByRef by default

' VB.NET - ByVal default
Sub ProcessData(data As String)  ' ByVal by default
Sub ProcessData(ByRef data As String)  ' Explicit ByRef

' VB6 - On Error
On Error Resume Next
On Error GoTo ErrorHandler

' VB.NET - Try-Catch
Try
    ' Code
Catch ex As Exception
    ' Handle error
End Try
```

### Common Migration Issues

```vb
' VB6 - Fixed-length strings
Dim name As String * 50

' VB.NET - Use regular string and PadRight
Dim name As String = "John".PadRight(50)

' VB6 - Currency type
Dim amount As Currency

' VB.NET - Use Decimal
Dim amount As Decimal

' VB6 - Control arrays
Dim TextBox(5) As TextBox

' VB.NET - Use collection
Dim textBoxes As New List(Of TextBox)()

' VB6 - Let/Set keywords
Let x = 5
Set obj = New MyClass

' VB.NET - Assignment without keywords
Dim x As Integer = 5
Dim obj As New MyClass()
```

## COM Interop from VB.NET

### Early Binding (Type Library Reference)

```vb
' Add COM reference in project
' Tools -> Add Reference -> COM -> Excel Object Library

Imports Excel = Microsoft.Office.Interop.Excel

Public Sub ExportToExcel(data As DataTable)
    Dim excelApp As Excel.Application = Nothing
    Dim workbook As Excel.Workbook = Nothing
    Dim worksheet As Excel.Worksheet = Nothing

    Try
        excelApp = New Excel.Application()
        workbook = excelApp.Workbooks.Add()
        worksheet = CType(workbook.Worksheets(1), Excel.Worksheet)

        ' Write headers
        For col = 0 To data.Columns.Count - 1
            worksheet.Cells(1, col + 1) = data.Columns(col).ColumnName
        Next

        ' Write data
        For row = 0 To data.Rows.Count - 1
            For col = 0 To data.Columns.Count - 1
                worksheet.Cells(row + 2, col + 1) = data.Rows(row)(col)
            Next
        Next

        excelApp.Visible = True
````
END THIRD-PARTY FILE b34a76fde8ae88cd

The third-party file has ended. Everything between the b34a76fde8ae88cd tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2736 of 9563 bytes. © Claude MPM Team · MIT · https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/visualbasic/legacy/vb6-legacy/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
