Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Understanding Unicode

VB4 introduces the use of double-byte characters. Most of this is transparent to the programmer and requires no special consideration. When calling API functions or reading/writing to a file VB will handle the conversion for you automatically. However, there may be times when you want to force a condition that goes against VB's will. For example, you might want to write Unicode to a file, pass a Unicode string to a function, or receive a Unicode string from a routine. In these cases you will have to use VB4's new Byte declaration. A String Byte can vary between one or two bytes depending upon how it is used. A Byte-byte is exactly that: one byte. To convert a string variable into a byte array, use this code:
 Redim MyByteArray(0 to len(MyString$)-1) as Byte
MyByteArray() = StrConv(MyString$, vbFromUniCode)
To convert a byte array to a string:
 MyString$ = StrConv(BA(), vbUniCode)
Due to a bug or design limitation, VB4 does not allow you to convert a string to a binary array that is part of a Type structure. For example:
 TYPE MyByteType
	Bytes( 0 to 255) as Byte

Dim MBA as MhByteType

MBA.Bytes() = StrConv(MyString$, vbFromUniCode) 
returns an error. However,
 MyString$ = StrConv(MBA.Bytes() , vbUniCode) 
works as expected.
MicroHelp Uninstaller
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date