|
Strings in Visual Basic 6.0 (part 1)In Visual Basic 6.0, a String is an object that may contains 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)
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2009 Chilkat Software, Inc. All Rights Reserved. .