The Different Upgrade EWIs

The Different Upgrade EWIs

The Upgrade Wizard can generate 50 different EWIs. Let s examine each one, grouped by EWI type.

Upgrade Issues

  • <statement> <statementname> is not supported Marks the Calendar statement, Load <formname> statement, GoSub, or On <expr> GoSub. The workaround for Calendar is to create a class that inherits from the System.Globalization.Calendar class. You can replace Load <formname> with code that creates a new instance of the form. GoSub is best fixed by reimplementing the routines as procedures.

  • <functionname> function is not supported Added when the following functions are used: CVErr; IMEStatus; AscB, MidB, ChrB, and the other B functions; VarPtr, ObjPtr, and StrPtr.

  • DoEvents does not return a value Added when code uses the return value of DoEvents. (In Visual Basic 6 it returns the number of open forms.) Although .NET provides no way to get the number of open forms, you can implement your own forms collection to do this. See Chapter 15 for more details.

  • Declaring a parameter As Any is not supported Added when an API has a parameter with a type of As Any. See Chapter 11for tips on fixing API problems.

  • Declaration type not supported: <declaration type> Added to variable declarations not supported in Visual Basic .NET: arrays of fixed-length strings, references to a private enumerator from within a public enumerator, enumerator values assigned to color constants, arrays with more than 32 dimensions, arrays with negative upper bounds, and Font objects declared WithEvents.

  • Constant <constantname> was not upgraded Some constants can t be upgraded to Visual Basic .NET.

  • Unable to determine which constant to upgrade <constantname> to Added when a constant could upgrade to one of several Visual Basic .NET constants and the wizard can t determine from the context which constant is appropriate.

  • LSet cannot assign one type to another Added when code uses LSet to assign a user-defined type from one type to another. The solution is to add a custom CopyTo method to the structure that copies the property in the source structure to corresponding properties in the destination structure.

  • COM expression not supported: Module methods of COM objects Added when code uses a module method. This issue is discussed in Chapter 13

  • Objects of type vbDataObject are not supported Added to the VarType function when the Upgrade Wizard detects that you re testing for VbVarType.vbDataObject (value 13). Objects that don t support the IDispatch interface can t be used in Visual Basic .NET. This is a rare issue.

  • <objecttype> object <object> was not upgraded Added to code that uses the Printers collection, Forms collection, or Scale-modeConstants.

  • Property <object>.<property> was not upgraded Added when a property cannot be upgraded automatically. See Appendix A for a complete list of properties and their mappings from Visual Basic 6 to Visual Basic .NET.

  • <objecttype> <object> could not be resolved because it was within the generic namespace <namespace> Added when code uses members of a variable declared as Form or Control. For information on fixing this type of soft-binding issue, see Chapter 10.

  • Unload <object> was not upgraded Added when Unload is used with a soft-bound form or control.

  • A string cannot be used to index the <variablename> control collection In Visual Basic 6, all collections could be indexed by a name or by a numeric key. In Visual Basic .NET, only hash tables and the VB collection can be indexed by a name. Most other collections, such as the Windows Forms controls collection, have only a numeric key index.

  • Event parameter <parameter name> was not upgraded Added when a form has an Unload or QueryUnload event. Windows Forms doesn t support the Cancel property for Unload or the UnloadMode property for QueryUnload.

  • Form property <formname>ScaleMode is not supported In Visual Basic .NET, you can t set the scale mode at run time.

  • <objecttype> property <variable>.<property> is not supported at run time Added when code sets a property that is read-only at run time.

  • ListBox ComboBox property <control>.NewIndex was not upgraded Added when code uses the NewIndex property of a ComboBox or ListBox control. NewIndex is not supported in Windows Forms.

  • <control> was upgraded to a Panel, and cannot be coerced to a PictureBox PictureBoxes are upgraded to Panels if they contain child controls. This EWI is added when the Panel is then passed to a method that accepts a PictureBox parameter.

  • <controltype> Property <control>.<property> does not support custom mouse pointers Added when code sets a custom mouse pointer. Custom mouse pointers are not automatically upgraded to Visual Basic .NET. You can rewrite your custom mouse pointer logic to use cursors. You can then load a cursor from a .cur file or a .resx file and set the cursor for a particular control.

Upgrade ToDos

  • Uncomment and change the following line to return the collection enumerator Added to collection classes. The Upgrade Wizard upgrades most of the collection class code, but you need to finish the upgrade by adding the collection enumerator. In most cases, this means simply uncommenting one line.

  • Code was upgraded to use <function> which may not have the same behavior Added to code that assigns a ByteArray to a string. In Visual Basic .NET, strings with an odd number of bytes will cause an exception because strings are stored in Unicode and therefore need two bytes per character. You should modify your code to ensure that the byte array is of an even length.

  • Initialize must be called to initialize instances of this structure As we discussed previously, this EWI is added to types (upgraded to structures) when the type contains a fixed-size array. When declaring a variable of this type, you will need to call the Initialize method to initialize the array.

  • Add a delegate for AddressOf <methodname> Added to code that uses AddressOf. See Chapter 11for more information on using AddressOf in Visual Basic .NET.

  • LoadResStrings method may need to be replaced The Visual Basic 6 AppWizard often generated a LoadResStrings function. This function is not automatically upgraded to Visual Basic .NET. If your code uses the unmodified AppWizard function, you can replace it with the suggested code in Help.

Upgrade Warnings

  • As <variable type> was removed from ReDim <variable> statement Arrays can be redimensioned using the ReDim statement only as the type they were originally defined as.

  • Arrays can t be declared with New You can t declare arrays of classes with New. Variable declarations of the form Dim x(10) As New Class1 are not allowed in Visual Basic .NET. The workaround is to initialize the classes when they are declared or as they are needed.

  • Structure <variable> may require marshalling attributes to be passed as an argument in this Declare statement Added to APIs when a structure is being passed. For information on marshalling attributes, see Chapter 11.

  • Arrays in structure <structure variable name> may need to be initialized before they can be used If a COM interface defines a structure with a fixed-size array, the array might need to be initialized before it can be used.

  • Array xxx may need to have individual elements initialized If an array of structures has been declared or redimensioned using ReDim, and the structure contains a fixed-length array, you will need to call Initialize for each member of the array.

  • Lower bound of array <variable> was changed from <lower bound> to 0 Arrays in Visual Basic .NET must have a lower bound of 0. If the array has a lower bound of anything other than zero, it is changed to 0 and the wizard generates this EWI.

  • Can t resolve the name of control <controlname> When the Upgrade Wizard needs to resolve the name of a control within a control array and it can t because the index is a variable, this warning is added.

  • ParamArray <parameter> was changed from ByRef to ByVal In Visual Basic .NET, ParamArrays can be passed only by ByVal.

  • Use of Null/IsNull detected Null is not supported in Visual Basic .NET, so it is upgraded to the closest equivalent, System.DBNull.Value. IsNull is changed to IsDBNull. You can t rely on DBNull having the same behavior as Null in Visual Basic 6. Also, Visual Basic 6 functions that accepted Null as a parameter and could return Null such as Left and Right now work only with strings. Null propagation is no longer supported in Visual Basic .NET. If Null is used in arithmetic expression, it will cause a run-time exception.

  • <functionname> has a new behavior Some functions have different behaviors in Visual Basic .NET, and this EWI warns you of the difference. Here are two of the key differences:

    IsObject(<object>) is upgraded to IsReference(<object>) and, unlike its behavior in Visual Basic 6, returns True if the object is empty and True if the variable is a string. The Dir function no longer returns the directory entries . and ..

  • Class instancing was changed from <instancing type> to public Single-use classes are changed to public classes during an upgrade.

  • Sub Main won t be called at component startup If a DLL has a Sub Main in it, it won t be called when the first class is created.

  • Application will terminate when Sub Main() finishes In Visual Basic 6, the application finishes when the End statement is called, or when all forms and objects are unloaded or destroyed. In Visual Basic .NET, the application ends when the End statement is called or when the startup object stops running. If your application has Sub Main as its startup object, the application will end when Sub Main ends. Several workarounds exist, including the use of System.Windows.Forms.Application.Run to create forms from within Sub Main. Forms loaded in this manner keep the application running once Sub Main finishes.

  • <object> event <variable>.<event> was not upgraded Some events can t be upgraded to Visual Basic .NET. These events are changed into procedures and won t be fired as they were in Visual Basic 6. You have to call them yourself if you want to run the code. This applies to the OLEDrag and OLEDragOver events and to all Font events.

  • Event <object>.<event> may fire when form is initializedSome events will be fired as the component is initialized. For example, if a check box has a default state of being selected, when the form is initialized, the CheckBox.CheckStateChanged event will fire. This leads to subtle differences if your event code refers to other controls that aren t fully created when this event is fired. You should modify your code to cope with this new behavior. This EWI is added for the following events:

OptionButton.Click

upgraded to CheckChanged

Form.Resize

upgraded to Resize

TextBox.Change

upgraded to TextChanged

ComboBox.Change

upgraded to TextChanged

CheckBox.Click

upgraded to CheckStateChanged

ComboBox.Click

upgraded to SelectedIndexChanged

DriveListBox.Click

upgraded to SelectedIndexChanged

ListBox.Click

upgraded to SelectedIndexChanged

  • Value <value> for <controltype> property <control>.<property> could not be resolved Some properties and property enumerators have changed from Visual Basic 6 to Visual Basic .NET. This EWI is generated if the Upgrade Wizard can t map a property or property enumerator. It usually occurs because the property is being assigned to a variable or return value of another function that can t be resolved.

  • Couldn t resolve default property of object <objectname> In some projects, this is the most common EWI you will see. It is added whenever a late-bound variable is set to a value. The Upgrade Wizard can t determine whether the assignment is to the variable or to the default property of the variable. Because it is late-bound, the wizard knows nothing about the variable and therefore generates this EWI.

  • <function> parameter <parameter> is not supported, and was removed The Wait parameter of AppActivate, the HelpFile and Context parameters of MsgBox, and InputBox are not supported in Visual Basic .NET. These parameters are removed during an upgrade.

  • Assignment not supported: KeyAscii to a non-zero value In Visual Basic .NET, the keypress parameter KeyAscii (now KeyPressEventArgs.KeyChar) can t be changed. If you have code that sets KeyAscii to 0, this is upgraded to KeyPressEventArgs.Handled = True. Code that sets it to any value other than 0 is marked with this warning.

  • Timer property <controlname>.Interval cannot have value of 0Timer.Interval = 0 deactivated a timer control in Visual Basic 6. In Visual Basic .NET, use the Enabled property to enable or disable the timer. Setting Interval to 0 causes an exception.

Design Errors

Design errors apply to forms and controls and are usually inserted only into the upgrade report. We ve noted the EWIs that can be inserted into code.

  • <controltype> control <controlname> was not upgraded This EWI is added to the report for controls that aren t supported in Windows Forms. The control is replaced with a red label placeholder. This EWI will occur with the following controls: OLE Container, Non horizontal/vertical lines, DAO Data, RDO Data, UpDown ActiveX, and the Shape control with the shape set to Oval or Circle.

  • <controltype> property <controlname>.<propertyname> was not upgraded Added when a property or method does not map from Visual Basic 6 to Visual Basic .NET. This EWI is also added to code if the property or method is used at run time.

  • <controltype> property <controlname>.<propertyname> has a new behavior Added to the report when a property, method, or event behaves differently in Visual Basic .NET. This issue is added for the following properties, methods, and events:

    • Control.Keypress event

    • ComboBox.Change event

    • Form.Activate event

    • Form.Deactivate event

    • Form.Picture property

    • Form.QueryUnload event

    • Form.Terminate event

    • Form.Unload event

    • Form.ZOrder property

    • HScrollBar.Max property

    • Image.Stretch property

    • ListBox.Columns property

    • ListBox.ItemCheck event

    • OptionButton.Click event

    • PictureBox.AutoSize property

    • Screen.MousePointer property

    • TextBox.TextLength property

    • UserControl.Picture property

    • VScrollBar.Max property

  • PictureBox property <controlname>. Picture will be tiled Added for a PictureBox with child controls. If a PictureBox contains child controls, it is upgraded to a panel because PictureBoxes in Windows Forms are not control containers. The background image of a Panel is always tiled.

  • ListBox ComboBox property <control>. ItemData was not upgraded Added when ListBoxes and ComboBoxes have ItemData set at design time. The ItemData property is not upgraded. (Note that run-time use of ItemData is upgraded.) The solution is to set the ItemData information for the ListBox or ComboBox at run time.

  • Only TrueType and OpenType fonts are supported in Windows Forms Windows Forms doesn t support raster fonts. If a control has its Font property set to a raster font, the font is changed to the default Windows Forms font (8-point Microsoft Sans Serif). This issue doesn t apply to ActiveX controls, which maintain their own fonts.

Global Warnings

  • <objectname> is not a valid Visual Basic 6.0 file and was not upgraded The project item (form, module, or other item) has an invalid file format perhaps it is corrupt or a Visual Basic 4 file. This file is ignored during the upgrade.

  • Could not load referenced component <reference>. It is recommended you install Visual Basic 6.0, with all referenced components, and ensure the application compiles and runs before upgrading. Added when a reference, such as an ActiveX control or class library, cannot be found. The best way to avoid this issue is to ensure that the project runs on the machine before upgrading. The Upgrade Wizard needs to load all your project s references to examine the type libraries, create wrappers, and instantiate ActiveX controls. If this problem occurs, the upgrade is canceled.

  • Could not find file: <projectitemtype> <filename>. Please make sure this file is present before upgrading this project. Added when a file can t be found. This warning can be issued if a file is located on a network share that is not available. If this problem occurs, the upgrade is canceled.

  • <projectitemtype> <filename> is a Visual Basic 5.0 file. For best results, upgrade the <projectitemtype> to Visual Basic 6.0 before upgrading it to Visual Basic. NET. Added to the upgrade report whenever a project with a Visual Basic 5 form, class, and so on is upgraded.

  • The referenced component <reference> is missing a design time license Added when the design-time license for a control is not installed. This warning usually occurs because a control is installed as part of a setup, without its design-time license. The Upgrade Wizard needs the design-time license because it instantiates ActiveX controls during the upgrade so that they can retrieve their properties for a Visual Basic 6 form. The Visual Basic .NET installation includes a registry file with the licenses for all the Windows Common controls. These licenses are stored in a registry file in the Extras directory; they are not installed with Visual Basic .NET.

  • The referenced project <projectname> is either not compiled or out of date. Please re-compile the project. Occurs when a project references another project that hasn t been compiled. The solution is to compile the referenced project to a DLL. If this problem occurs, the upgrade is canceled.

  • MTS/COM+ objects were not upgraded If a project has references to the Microsoft Transaction Server Type Library or the COM+ Services Type Library, they are removed during upgrade. These references will not work in Visual Basic .NET and should be replaced with .NET COM+ services objects. See Chapter 16 for more details.

  • The following line couldn t be parsed Added to a code module when a line could not be upgraded because of syntax errors. The line is copied as is into the Visual Basic .NET module and marked with this EWI.

  • <objecttype> <objectname> was not upgraded Applies to ActiveX documents and property pages. These project items can t be automatically upgraded.

Upgrade Notes

  • There may be differences in databinding behavior Added to the upgrade report whenever an application has ADO data binding. The warning has a hyperlink to a Help topic that gives general advice about fixing issues with ADO data binding.

  • Def <variabletype> statement was removed. Variables were explicitly declared as type <type>. Added to the declaration section of modules that had statements such as DefInt and DefStr. The variables are changed to be explicitly declared. This message is purely informative.

  • <variable> was changed from a Constant to a Variable A constant was changed to a variable because the data type can t be stored as a constant in Visual Basic .NET. This message is added for constants declared as colors.

  • NewEnum property was commented out When collection classes are upgraded, the Upgrade Wizard comments out the old NewEnum property and inserts a ToDo comment describing how to implement the collection enumerator.

  • Object <variable> may not be destroyed until it is garbage collected Added to code that sets an object to Nothing. Objects set to Nothing aren t actually destroyed until the .NET Garbage Collector performs its next collection.

  • IsMissing(<variable>) was changed to IsNothing(<variable>) The IsMissing function was replaced with IsNothing.

  • #If #EndIf block was not upgraded because the expression <expr> did not evaluate to True or was not evaluated If your code has conditional compilation statements, code in the False branch will not be upgraded. The Visual Basic 6 code will be copied as is into your upgraded application.

  • Remove the next line of code to stop form from automatically showing Added to multiple document interface (MDI) child forms when the Visual Basic 6 MDIForm has the property AutoShowChildren = True. The Upgrade Wizard inserts the line Me.Show into the child form to give it the same behavior as in Visual Basic 6.

  • The following line was commented to give the same effect as VB6 Code that does nothing in Visual Basic 6 but would have an effect in Visual Basic .NET is commented out. This applies to code that sets Form.BorderStyle at run time.

  • <control>.<event> was changed from an event to a procedureAdded to these events: HScrollBar.Change, HScrollBar.Scroll, VScrollBar.Change, VScrollBar.Scroll, and MenuItem.Click. The event was changed to a procedure and called from another event. This change is made because Windows Forms combines some events that used to be separate events into a single event.

  • <statement> was upgraded to <statement> Added when a statement is upgraded to a corresponding statement with a different name. This note is added for the Erase statement, which is upgraded to System.Array.Clear.



Upgrading Microsoft Visual Basic 6.0to Microsoft Visual Basic  .NET
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET w/accompanying CD-ROM
ISBN: 073561587X
EAN: 2147483647
Year: 2001
Pages: 179

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net