Microsoft KB Archive/311338

= You receive a &quot;Constant vbFromUnicode was not upgraded&quot; message in Upgrade Report after you upgrade a Visual Basic 6.0 project to Visual Basic .NET or Visual Basic 2005 =

Article ID: 311338

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005 Express Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



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.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
  Create a Visual Basic 6.0 project that contains the following code: ' Convert String data to ANSI byte array. Bytes = StrConv(SomeString, vbFromUnicode)  Start Microsoft Visual Studio .NET or Visual Studio 2005.  Open the Visual Basic 6.0 project in Visual Studio .NET or in Visual Studio 2005. Notice that the Upgrade Wizard migrates the code in step 1 as follows: Bytes = System.Text.UnicodeEncoding.Unicode.GetBytes(StrConv(SomeString, vbFromUnicode)) 

