- Created by Luke Cerwin , last modified on Jun 28, 2022
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 3 Next »
This document describes the procedures and utilities for building real time Web based graphic screens under Visual Basic .NET 2003. These screens may be animated using real time data from a control system. Screens may be displayed on any workstation using a browser such as Microsoft Internet Explorer 5.5.
Upgrade TPRI VB6 Screens to VB.NET
Click Start
Select Programs
Select Microsoft Visual Studio .NET 2003
Click Microsoft Visual Studio .NET 2003 to start .NET 2003 development environment
Microsoft Upgrade Tools will handle about 80% of the conversion (depending on the project). But unfortunately the rest of the work has to be done manually.
Before attempting upgrade, make sure the vb6 project can be opened on your system. This will ensure you have the correct controls installed and the module paths correct.
Within .NET 2003 development environment click Open Project button
Select a VB6 project (vbp file)
Welcome to Visual Basic Upgrade Wizard window will open, Click Next
Choose a project Type: ensure that “DLL/custom control library” is selected, Click Next
Select the new VB.NET project directory name and location
Folder does not exist, create it? Click Yes, then click Next to begin
If you receive an Upgrade Failed error, it is because referenced modules from the VB6 project cannot be found in the specified location. Copy the modules folder to the correct location and repeat from step 2
Any controls in the original VB6 project that are not Microsoft standard controls will not be converted to the corresponding new .NET assemblies (The upgrade tools have no way of knowing there is any new .NET assembly for a given COM component). Instead the upgrade tools will treat the control just as there is no corresponding .NET assembly. It will create the interop/Ax* wrappers for the control (COM). Since all the TPRI standard controls are converted to .NET there is no need to keep any of the interop/Ax files around anymore.
Most of the common modules are included in the TPRI.BaseControl or TPRI.BaseScreen. But there are situations that some of the screens have their own special module(s). In that case the module(s) should remain in the project.
The .NET version of IobjSafe is implemented in the section: Signing of TPRI Screens.
The option of using Namespace to group the assemblies will also change the way we name the solutions, projects and classes.
In windows explorer, browse to newly created project directory
Delete the directory _UpgradeReport_Files
Delete the files:
_UpgradeReport.htm
ErrRpt.vb
IobjSafe.vb
Modules.vb
Any Interop/Ax*.dll file
Any Interop/Ax*.vb fileBack in the solution explorer of the .NET design environment:
Change the file names accordingly:
solution name
project name
.vb nameDelete the files:
_UpgradeReport.htm
ErrRpt.vb
IobjSafe.vb
Modules.vb
Any Interop/Ax*.dll file
Any Interop/Ax*.vb fileSave all files
For the same reason stated above there is no need to keep any of the interop/Ax or IObjectSafety reference anymore. It is also important to remove any COM object reference. Replace the COM components with the corresponding .NET assemblies.
Expand the References folder
The interop files are shown as just tpri*. You can show their full names by selecting them and looking at the properties for that file.
2. Replace any reference to Interop/Axtpri* with corresponding tpri .NET control
Easiest way is to add all references first:
Right-click References, select Add Reference
Browse to the Bin directory which contains the tpri control dlls and select the corresponding TPRI.* file
Continue to browse to add the rest of the tpri controls
Be sure to add the TPRI.BaseScreen and TPRI.BaseControl references
3. If you receive an error concerning changing where the array references are found, click OK
4. Remove the references:
IObjectSafetyTLB
VBRUN
Std*
MSDATASRC
Any AxucxxxxxArray
5. Add any other necessary .NET reference
TPRI.xxxx
TPRI.shape is needed when TPRI.ActiveShape is used
Gigasoft.ProEssentials.dll
C1.win.c1flexgrid.dll
C1.Common.dll
…
'Statement Option Explicit On' forces explicit declaration of all the variables in the module. (The default: Option Explicit On)
VB6 is not a type-safe language. VB.Net is type-safe (like C). 'Statement Option Strict On' enforces strict type checking. (The default: Option Strict Off)
View Code of ProjectName.vb
At the top, set the Options:
Option Explicit On
Option Strict OnOn the following line, Remove the control class attribute: <System.Runtime.InteropServices.ProgId("ucxxxx_NET.ucxxxx")>
Change the Public Class name to match the project name
The TPRI.BaseScreen includes most of the shared code including sub StartFromAsp, Link, events GotoUrl and ErrorTerminate. It also includes the code to run TSentry screens under Web Browser. All Tsentry screens are built on top of TPRI.BaseScreen that means to inherit TPRI.BaseScreen instead of System.Windows.Forms.UserControl.
Microsoft Upgrade Tools create an argument class for each of the VB6 events that have any argument. The argument class approach is Microsoft .NET's standard way of passing all parameters as one argument. Here we choose to use the way we all are familiar with (each parameter as a separate argument).
Change the line: Inherits System.Windows.Forms.UserControl to Inherits TPRI.BaseScreen
Remove IobjectSafety related code:
Delete the line: Implements IObjectSafetyTLB.IobjectSafety
Delete the two sub routinesRemove URL related code (ex):
GoToURLEventArgs class
Link sub routineRemove Events (ex):
GotoUrl
ErrorTerminate
By modifying the code in the region, the Windows Form Designer-generated code will allow us to retain most of the properties of the original controls including, most importantly, location and size of the controls. Most of the property settings will not be affected. But some of the property settings need to be manually corrected because of the name change, type change or even add/removal.
Expand Region: Windows Form Designer generated code
In the declaration section (noted by 'Required by the Windows Form Designer’), replace any Interop/Ax controls with TPRI controls. The easiest way is with a find/replace (since there are hundreds).
Ignore the Ax*Array errors for now.
Correct the property name and value if necessary. (Some of the TPRI control properties are changed.)
Modules and classes live in namespaces. All the classes defined in the standard Tsentry controls and screens are grouped under namespace TPRI. You are encouraged to use your own namespace for a set of local screens.
Use Namespace <namespace> (for example: TPRI)
Name class name as original class name <class> without the prefix (tpri)
Make sure to close design view if it is open
Right click project node in the Solution Explorer and select Properties
Select Common Properties | General
Enter Assembly name as: <namespace>.<class>
Enter Root namespace as: <namespace>
Click OK button
Save changes for the project
Control array in VB6 as we know does not exist anymore in VB.NET. Microsoft Upgrade Tools will create an array for each of the VB6 standard control array using the functionalities in Microsoft.VisualBasic.Compatibility.dll. Tsentry includes the customized control array classes for some of the TPRI standard controls (ActiveShapeArray, CmdButtonArray…).
For Microsoft WinForm controls there is an option to create control array using Microsoft.VisualBasic.Compatibility class. Microsoft upgrade tool will convert the existing VB6 control arrays.
Reference Microsoft.VisualBasic.Compatibility.dll
Friend WithEvents labels As Microsoft.VisualBasic.Compatibility.VB6.LabelArray
For the Tsentry standard controls use the included control array classes (ActiveShapeArray, CmdButtonArray…).
- No labels