From claude-vb6-skills
Catalog of common utility functions that VB6 codebases typically maintain in a shared module (often named modUtils, modFuncoes, modCommon, or similar). Activates when writing or editing VB6 code that handles NULL coalescing, SQL value formatting, string sanitization for SQL literals, accent/diacritic removal for searching, padding (left/right), substring extraction between markers, CNPJ/CPF (Brazilian tax ID) validation, MsgBox dialog wrappers, IDE-vs-compiled detection, regex via VBScript.RegExp, ADO Command parameter helpers, ListView and grid serialization, and common helpers prefixed with fg_ (function global). The goal is to recognize these patterns and reuse existing project utilities instead of reinventing them. Triggers on tasks involving string manipulation, validation, NULL handling, formatting, or any common helper that likely already exists in the project's utility module.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-vb6-skills:vb6-utilitiesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
VB6 codebases typically maintain a shared utility module (commonly named
VB6 codebases typically maintain a shared utility module (commonly named
modUtils, modFuncoes, modCommon, or similar) that accumulates helpers
over years of development. Before writing a utility function from scratch,
check whether one already exists.
This catalog describes the functions you are most likely to find. Names and exact signatures vary per project; the names below are representative of the patterns to look for.
fg_ prefix — "function global"Many codebases use the fg_ prefix for stateless utility functions exposed
project-wide. Examples: fg_isNull, fg_Coalesce, fg_InIDE. When you see
this prefix, treat the function as part of the utility layer — reusable,
side-effect-free, safe to call from anywhere.
MsgBoxXxxMost projects wrap MsgBox to integrate with logging, theming, and consistent
button layouts. Typical names: MsgBoxCritical, MsgBoxInfo, MsgBoxWarning,
MsgBoxQuestion, MsgBoxOption. Use the wrapper, not raw MsgBox.
fg_isNull(value, defaultValue) As VariantReturns defaultValue when value is Null, otherwise returns value.
Equivalent to SQL's ISNULL or COALESCE with one fallback.
strName = fg_isNull(rs("custName").Value, "")
lngCount = fg_isNull(rs("total").Value, 0)
fg_Coalesce(value1, value2, ...) As VariantReturns the first non-Null value in the list, or Null if all are Null.
strContact = fg_Coalesce(strPhone, strMobile, strEmail, "no contact")
fg_NullIf(value, valueIfEqual) As VariantReturns the string "Null" (for SQL literal use) when value matches
valueIfEqual, otherwise returns value. Used when building SQL strings
manually.
fg_NullIfDB(value, valueIfEqual) As VariantReturns actual Null (not the string "Null") when value matches
valueIfEqual, otherwise returns value. Used when assigning to ADO
parameter values.
ToSQL(value, [ForceString], [MaxChars]) As StringFormats any Variant as a SQL literal: dates as 'dd/mm/yyyy', numbers
with . decimal separator, strings with apostrophes doubled, Null as
Null.
strSQL = "INSERT INTO Customer (custName, custBirth) VALUES (" & _
ToSQL(strName) & ", " & ToSQL(dtmBirth) & ")"
Modern code prefers parameters over ToSQL. See vb6-ado-late-binding.
ToSQL remains useful for:
ShowADOCommand output)SanitizeSqlString(s As String) As StringDoubles apostrophes (' → '') to prevent SQL literal breakage. Called
internally by ToSQL. Direct use is mainly for backward compatibility with
older code paths.
Note: sanitization is a fallback. Parameters are the correct solution.
RemoveAccents(sText As String) As StringStrips diacritical marks (á → a, ç → c, etc.) for accent-insensitive search and matching.
TrimAll(sText As String) As StringStrips all whitespace including non-breaking spaces, tabs, and CRLF — beyond
what built-in Trim does.
TrimLeadingZeros(value As String) As StringRemoves leading zeros from a numeric string. "00012345" → "12345".
PadLeft(sText, [sChar], [iLen]) As StringPadRight(sText, [sChar], [iLen]) As StringString padding to a target length with a fill character (default space).
strInvoiceNum = PadLeft(CStr(lngID), "0", 9) ' "000012345"
RemoveDup(sText, sChar) As StringCollapses consecutive occurrences of sChar into one. "a,,b,,,c" → "a,b,c".
RemoveDuplicates(pText, [Delimiter]) As StringRemoves duplicate entries from a delimited list. "a,b,a,c,b" → "a,b,c".
RemoveEnd(sText, [iQtChar]) As StringRemoves the last N characters. Useful for trailing separators after a loop:
PathBuild = PathBuild & dir & "\" then RemoveEnd(PathBuild, 1).
MidFirst(sText, sChar) As StringReturns the substring after the first occurrence of sChar.
MidLast(sText, sChar) As StringReturns the substring after the last occurrence of sChar.
SubstringBetween(sString, markStart, markEnd, [StartEnd]) As StringReturns the substring between two markers. SubstringBetween("Hello [World]!", "[", "]") → "World".
SubstringLeft(sString, markEnd) As StringReturns the substring left of the marker.
CountOccurrences(sText, sStringToCount) As IntegerCounts non-overlapping occurrences of a substring.
ReplaceBetween(Expression, FindIni, FindEnd) As StringReplaces everything between two markers (inclusive of the markers).
IsValidCNPJ(CNPJ As String) As BooleanValidates a Brazilian company tax ID (CNPJ): format, length, and check
digits. Accepts formatted ("12.345.678/0001-90") or unformatted
("12345678000190") input.
IsValidCPF(CPF As String) As BooleanValidates a Brazilian personal tax ID (CPF): format, length, and check digits.
IsValidEmail(mailAddress As String) As BooleanValidates email address format via regex.
IsNumericPad(KeyCode As Integer) As BooleanReturns True if the key code corresponds to a numeric input (0-9, decimal,
backspace, arrows). Used in KeyDown/KeyPress handlers for numeric-only
text fields.
ToHour(sec As Single, [IncludeSeconds]) As StringConverts seconds to HH:MM:SS or HH:MM format.
fg_NumberToWords(nValue As Double, CurrencySingular, CurrencyPlural) As StringRenders a numeric value as written-out currency ("one hundred and twenty-three reais and forty-five cents").
Trunc(value, DecimalPlaces As Byte) As CurrencyTruncates a number to N decimal places (no rounding).
RoundOrTrunc(value, DecimalPlaces As Byte) As CurrencyTruncates or rounds based on a project-wide setting
(gParameters.RoundOrTruncate).
ApplyFiscalRounding(dblTotalValue, [decimalPlaces]) As DoubleApplies fiscal rounding rules (banker's rounding or specific Brazilian fiscal conventions).
Encrypt(Input As String) As StringDecrypt(Input As String) As StringSymmetric scrambling for storing low-stakes values (window position, recent file list) in INI files. Not cryptographically secure — do not use for passwords or sensitive data.
fg_EncryptKey(sKey As String) As StringProject-specific key encoding for connection strings stored in config files.
MsgBoxCritical(Text As String)Critical error dialog. Always logged with Force = True.
MsgBoxInfo(Text As String)Informational dialog. Logged at normal level.
MsgBoxWarning(Text As String, [returnValue], [YesNoButtons]) As VbMsgBoxResultWarning dialog with optional OK-only or Yes/No buttons.
MsgBoxQuestion(Text, [DefaultButton], [YesNoButtons], ...) As VbMsgBoxResultYes/No confirmation dialog.
MsgBoxOption(Text, Option1, Option2, ...) As ByteTwo-button choice dialog with custom button captions.
Rule: new code never calls MsgBox directly. Always use the wrapper.
fg_InIDE() As BooleanReturns True when running inside the VB6 IDE, False when running as a
compiled EXE. Classic implementation triggers Debug.Print 1/0 which raises
in IDE but is removed by the compiler.
Public Function fg_InIDE() As Boolean
On Error GoTo erro
Static blnCached As Boolean
Static blnComputed As Boolean
If blnComputed Then
fg_InIDE = blnCached
Exit Function
End If
Debug.Print 1 / 0 ' raises in IDE, removed by compiler
blnCached = False
blnComputed = True
fg_InIDE = False
Exit Function
erro:
blnCached = True
blnComputed = True
fg_InIDE = True
End Function
CenterObject(o As Object)Centers a form or control within its container.
FocusOn(ctl As Object, [SelectText As Boolean])Sets focus to a control with optional auto-selection of contents.
PopulateCombo(cbo As ComboBox, rs As Object, [defaultID])Populates a ComboBox from a Recordset (column 0 as value, column 1 as display).
LV_ColumnSort(ListView, ...)Generic ListView column sort handler.
ListViewLineColor(lvw, ItemIndex, ToColor)Sets a row's background color in a ListView.
ListViewToJson(lvw, [useItemKey]) As StringExports a ListView's contents as JSON for persistence or transport.
LoadListViewFromJson(lvw, sJSON As String)Imports a ListView from a JSON string previously produced by ListViewToJson.
Serialize(Fields As Variant) As StringGeneric serializer that handles arrays, Dictionaries, Recordsets, and Field collections. Returns a delimited string for logging.
SerializeForm(frm As Object, [HumanReadable]) As StringIterates a form's controls and serializes their current values. Useful in error handlers to capture the UI state at the moment of failure.
SerializeListItem(lstView, lstItem) As StringSerializeListGrid(lstView, [lRow]) As StringListView and grid row serialization.
LastDayOfMonth(iMonth, iYear) As IntegerReturns the last day of a given month.
CreateFolder(DestDir As String) As BooleanCreates a directory tree (recursive), returning True on success.
RegExp(sPattern As String, sText As String, ...) As ...Wraps VBScript.RegExp (late-bound) for regex matching. Useful when the
project does not want a reference to the Regex type library.
EvaluateVBCode(Scode As String)Late-bound MSScriptControl.ScriptControl evaluation. Use cautiously — this
is eval for VB6 and carries the same risks.
GetSeqNumber() As StringReturns a project-wide unique sequence number (timestamp-based or counter-based depending on implementation).
Soundex(sText As String) As StringPhonetic encoding for fuzzy name matching.
Before adding a new helper function, look for an existing one:
fg_<thing> in the utility module<Thing> (PascalCase) in the utility modulemodUtils, modFuncoes, modString, etc.)If the helper does not exist, follow the project's naming conventions
(fg_ prefix or not, English or Portuguese, the file the helper belongs in)
when adding it.
npx claudepluginhub alexcassol/claude-vb6-skills --plugin claude-vb6-skillsProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.