Appendix C. Data Marshaling

When calling between the runtime environment and existing COM interfaces, the CLR performs automatic data marshaling for CLR types into compatible COM types. Table C-1 describes the Visual Basic to COM default data type mapping.

Table C-1. VB type to COM type mapping

VB type

COM type

Boolean VARIANT_BOOL
Char unsigned short
System.Sbyte Char
Byte Unsigned char
Short Short
System.UInt16 Unsigned short
Integer Int
System.UInt32 Unsigned int
Long Hyper
System.UInt64 Unsigned hyper
Single Single
Double Double
Decimal DECIMAL
Object VARIANT
String BSTR
Date DATE [a]
System.Guid GUID
1-dimensional arrays SAFEARRAY
Value types

Equivalently named struct

Enum

Equivalently named enum

Interface Equivalently named interface
Class Equivalently named CoClass

[a] COM dates are less precise, causing comparison problems.

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.