Chilkat Examples
Languages

Chilkat Software

 

Charset 101

 

Strings in Visual Basic 6.0 (part 1)

In Visual Basic 6.0, a String is an object that may contain characters in any language (English, Chinese, German, Greek, etc). VB6 strings store characters internally using Unicode.

The StrConv function is used to import to/from ANSI or Unicode:

    Dim s As String
    s = "abc"
        
    Dim unicodeBytes() As Byte
    Dim ansiBytes() As Byte
    
    ' Access the Unicode bytes directly:
    unicodeBytes = s
    ' Use StrConv to return the ANSI bytes:
    ansiBytes = StrConv(s, vbFromUnicode)
    
    ' Unicode is 2 bytes/char, therefore the unicodeBytes array contains 6 bytes.
    ' (LBound = 0, UBound = 5)
    MsgBox UBound(unicodeBytes)
    
    ' The ANSI charset (in this example) uses 1 byte/char, therefore the ansiBytes
    ' array contains 3 bytes.
    ' (LBound = 0, UBound = 2)
    MsgBox UBound(ansiBytes)

Next: Strings in Visual Basic 6.0 - Reading Text Files

© 2000-2022 Chilkat Software, Inc. All Rights Reserved. ..