VB6 Variant vs Byte Array

In Visual Basic 6.0, a Variant containing a byte array is different than a byte array.
For example, examine this code:

    ' Assume mime is a ChilkatMime object...
    Set mimePart = mime.GetPart(1)
    
    thefile = FreeFile()
    'Get the attachment filename
    FileName = mimePart.FileName
    'Get the attachment
    Dim mBody As Variant
    mBody = mimePart.GetBodyBinary
    If Len(mBody) > 0 Then
        Open FileName For Binary As #thefile
            Put #thefile, , mBody
        Close #thefile
    End If

The result is not what you expected. There’s a mysterious extra 12 bytes prepended to the content that is saved. Why? Because you saved the Variant structure as well as the contents of the Variant.
This is what you really wanted:

    ' Assume mime is a ChilkatMime object...
    Set mimePart = mime.GetPart(1)
    
    thefile = FreeFile()
    'Get the attachment filename
    FileName = mimePart.FileName
    'Get the attachment
    Dim mBody() As Byte
    mBody = mimePart.GetBodyBinary
    If UBound(mBody) > 0 Then
        Open FileName For Binary As #thefile
            Put #thefile, , mBody
        Close #thefile
    End If

In the above code fragment, mBody is a byte array. There is no Variant structure encapsulating the data. The content of the MIME body is saved exactly as you expected.

Note: There is an implicit conversion happening in this statement:

mBody = mimePart.GetBodyBinary

GetBodyBinary is a function that returns a Variant. However, mBody is declared as an array of Byte. Therefore, the VB6 runtime is converting the Variant to a byte array. In other words, it’s removing the Variant wrapping so-to-speak…

Visual Basic Font.Charset Property

Charset Name Charset Value
(Hex)
Charset Value
(Decimal)
Code-Page ID
ANSI_CHARSET 0x00 0 1252
DEFAULT_CHARSET 0x01 1
SYMBOL_CHARSET 0x02 2
SHIFTJIS_CHARSET 0x80 128 932
HANGUL_CHARSET 0x81 129 949
GB2312_CHARSET 0x86 134 936
CHINESEBIG5_CHARSET 0x88 136 950
GREEK_CHARSET 0xA1 161 1253
TURKISH_CHARSET 0xA2 162 1254
HEBREW_CHARSET 0xB1 177 1255
ARABIC_CHARSET 0xB2 178 1256
BALTIC_CHARSET 0xBA 186 1257
RUSSIAN_CHARSET 0xCC 204 1251
THAI_CHARSET 0xDE 222 874
EE_CHARSET 0xEE 238 1250
OEM_CHARSET 0xFF 255