You receive a "Constant vbFromUnicode was not upgraded" message in Upgrade Report after you upgrade a Visual Basic 6.0 project to Visual Basic .NET or Visual Basic 2005 (311338)
The information in this article applies to:
- Microsoft Visual Basic 2005 Express Edition
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
This article was previously published under Q311338 SYMPTOMS When you upgrade an application that converts Unicode
strings to an American National Standards Institute (ANSI) byte array by using
the StrConv function and the vbFromUnicode constant from Microsoft Visual Basic 6.0 to Visual Basic .NET or Visual Basic 2005,
the following UPGRADE comments appear in the Task List of the upgrade report
for the Visual Basic .NET or Visual Basic 2005 project:
'UPGRADE_ISSUE: Constant vbFromUnicode was not upgraded.
'UPGRADE_TODO: Code was upgraded to use System.Text.UnicodeEncoding.Unicode.GetBytes()
which may not have the same behavior.
Bytes = System.Text.UnicodeEncoding.Unicode.GetBytes(StrConv(SomeString, vbFromUnicode))
CAUSE Although Visual Basic .NET and Visual Basic 2005 support the StrConv function, Visual Basic .NET and Visual Basic 2005 do not support the vbFromUnicode constant. RESOLUTION To resolve this problem, use the Encoding object in the System.Text namespace to convert this application. You must change the code
in the Visual Basic .NET project as follows:
Bytes = System.Text.Encoding.GetEncoding(1252).GetBytes(SomeString)
The value 1252 in the parentheses represents the code page to be used in the
conversion. Code page 1252 includes characters for Western European languages,
including US English. You can also user other code pages. For example, you can
also use 1253 for Greek character conversion, or you can use 1251 for Cyrillic
conversion. STATUSThis
behavior is by design.REFERENCES For more information about how to migrate Visual Basic 6.0
projects to Visual Basic .NET or Visual Basic 2005, visit the following MSDN Web site:
| Modification Type: | Major | Last Reviewed: | 1/27/2006 |
|---|
| Keywords: | kbvs2005swept kbvs2005applies kbmigrate kbprb KB311338 |
|---|
|