Visual Basic Concepts
In locales where DBCS is used, a file may include both double-byte and single-byte characters. Because a DBCS character is represented by two bytes, your Visual Basic code must avoid splitting it. In the following example, assume Testfile is a text file containing DBCS characters.
' Open file for input. Open "TESTFILE" For Input As #1 ' Read all characters in the file. Do While Not EOF(1) MyChar = Input(1, #1) ' Read a character. ' Perform an operation using Mychar. Loop Close #1 ' Close file.
When you read a fixed length of bytes from a binary file, use a Byte array instead of a String variable to prevent the ANSI-to-Unicode conversion in Visual Basic.
Dim MyByteString(0 to 4) As Byte Get #1,, MyByteString
When you use a String variable with Input or InputB to read bytes from a binary file, Unicode conversion occurs and the result is incorrect.
Keep in mind that the names of files and directories may also include DBCS characters.
For More Information For background information on file processing, see "Working with Files" in "Processing Drives, Folders, and Files." For information on the Byte data type, see "Data Types" in "Programming Fundamentals."