VB6 Error 13: Type Mismatch

Error 13 occurs when a runtime value cannot be used as the type required by an assignment, expression, database operation, COM call or Windows API boundary.

Inspect the value, not only the declaration

Capture the failing statement and log TypeName, VarType and a safe representation of each input. A Variant may contain a number, string, date, object, Empty, Null or an array despite appearing harmless in the debugger.

  1. Handle Null explicitly before conversion; it is not an empty string or zero.
  2. Separate missing/empty input from valid zero values.
  3. Replace implicit conversions with checked, intentional conversions.
  4. Inspect database field types and parameter types at the failing row.
  5. Confirm the declared COM or API return type matches the installed interface.

Why it can be environment-dependent

Dates and decimalsLocale changes how ambiguous strings are parsed.
Database recordsOne row may contain Null, unexpected text or a wider numeric value.
COM/API resultA component version can return a different Variant subtype or interface.
Control valuesList and text controls may expose sentinel values before selection.

Reproduce with the exact input and regional settings before changing broad conversion rules. Validate at the system boundary so invalid data does not travel deep into calculations.

For object initialization failures see error 91; for recordset and provider behavior use ADO troubleshooting. The VB6 pillar provides the wider system context.

Describe your legacy system or problem

Share what still works, what failed, and what must be preserved.

EMAIL BOGLAR.NET