DragandDrop Functionality

Drag-and-drop capability is an important feature of most modern form-based applications. There are a number of important differences in drag-and-drop functionality between Visual Basic 6.0 and Visual Basic .NET. This section provides an overview of the differences so that you can better understand how they will affect your application. Drag-and-Drop Functionality in Visual Basic 6.0 Visual Basic 6.0 supports two kinds of drag-and-drop operations standard drag-and-drop functionality, which...

Customizing Your Installer

In most cases, a standard installer with default options is not sufficient to meet the deployment requirements of an application. You may need to add dialog boxes, text, Help files, and more, to your setup program. In Visual Basic 6.0, this required you to either modify the setup script file or modify the Setup1.exe project template used by the wizard. In Visual Basic .NET, you can use the project's properties and the editors provided in Visual Studio .NET to make these changes. The editors are...

Inventory to Upgrade

The first aspect to be considered in the application analysis is the inventory of resources and components involved in the upgrade process, which includes modules, third-party components, and intrinsic components. Some of these components are user-defined, and their implementation needs to be upgraded In addition to the source code that uses them. For third-party and intrinsic components it is necessary to upgrade the code that accesses the corresponding component in this case, for assessment...

File Access Through the File System Object Model

Another option available in Visual Basic .NET for accessing and manipulating files is to use the File System Object FSO model. This model provides objects and methods for working with files and folders directories in an object-oriented way. This model is provided through the Visual Basic Scripting type library Scrrun.dll . Using the FSO model, you can create or delete files and folders, obtain information about files and folders such as path information , and perform other manipulations such as...

Message Queuing and Queued Components

Message Queuing also known as MSMQ constitutes a platform that supports flexible and reliable communication between applications. Different applications can be integrated by implementing a communication environment where messages can be sent between applications in networks with varying degrees of reliability. Message Queuing enables applications that are running at different times to communicate across heterogeneous networks in a reliable manner, in spite of any unreliable components in the...

Create Test Plan and Test Code

The test plan documents the test cases that will be used to test the upgraded application. It also helps in planning and estimating the actual test effort that is required to prepare the test code and to execute the tests. Finally, the test plan helps in tracking the tests and their results, especially when there are multiple iterations or changes in specifications. Test plans are usually prepared very early in the upgrade life cycle. The information required to prepare a test plan include The...

Preparing the Environment

If possible, execute the upgrade process using a computer that has been configured similarly to the development environment that was used to create the original application. This will facilitate analysis of the original application and make it easier to execute the initial preparation tests and identify dependencies and other issues. There are two main environment aspect types that affect the upgrade process. The first of these affects the speed of the upgrade process this includes computer...

Serialization

When coding applications that do not have or need access to a database, there is frequently a need to store data used in the program for later retrieval. Before .NET, any attempt to serialize data required custom code. For example, if the programmer needed to serialize the information from a class or data structure, a procedure could have been written that would write each instance of the class structure to an XML document. Programming this code usually required a great deal of work and testing...

To complete the upgrade Pow

1. Add the EnterpriseServices reference to the project and a corresponding Imports statement to the class. 2. Change the class to inherit from the ServicedComponent class. Inherits ServicedComponent 3. Use one of the following two approaches to resolve the GetObjectContext warnings a. The first approach is to use the System.EnterpriseServices.ContextUtil class, which is the .NET Framework equivalent of GetObjectContext. The ContextUtil class obtains information about the COM object context....

Multithreading and the BackgroundWorker Component

Multithreading, or free-threading, refers to the ability of a program to execute multiple threads of operation simultaneously. Multithreading can be a powerful tool to use in component programming. By writing multithreaded components, you can create components that perform complex calculations in the background while leaving the user interface free to respond to user input. The .NET Framework offers more than one option for multithreading in components. The functionality in the System.Threading...

Visual Basic 60 Native Libraries VB VBA VBRUN

The Visual Basic 6.0 native libraries which provide much of the language's core functionality have been replaced by the .NET Framework itself. The .NET Framework provides the .NET languages with core functionality through the System namespace and other namespaces. The upgrade wizard automatically replaces calls to the Visual Basic 6.0 native libraries with calls to the equivalent .NET Framework objects and classes. For example, the following Visual Basic 6.0 code uses functions from the VB,...

Creating a Mobile Version of a Desktop Application

When you decide to create a new mobile application that is based on a desktop application, it is necessary to port and review several aspects of the original application. These aspects range from the user interface, to data access, and even to low-level manipulation of the target device. This section provides an overview of the steps that are necessary to port a desktop application to a mobile application. It also discusses some of the tools that are available to port the application, and it...

Test Strategy Based on the Iterative Methodology

Another possible test strategy for upgrade projects is based on the iterative development methodology. This test strategy overcomes the shortcomings of the waterfall-based test strategy and is best used in complete upgrade projects for complex applications and for staged upgrade projects for reasons explained later in this chapter. In a staged upgrade strategy, each project component is upgraded and is integrated with the system. The system consists of the .NET upgraded projects and the Visual...

Using Visual Basic NET Application Blocks

Microsoft offers several application blocks for the .NET Framework. Application blocks encapsulate certain key areas by adding a layer over the .NET Framework. They also aid faster application development and promote certain favored practices. Application blocks encapsulate an optimal way of doing things in the .NET Framework. You can reuse the application blocks to reduce the amount of redundant code. Application blocks are C and Visual Basic .NET classes that are distributed as Visual Studio...

Completing the Upgrade with Manual Changes 1

After your applications are upgraded, the most difficult errors to detect are the runtime errors. The migration assistant can detect many potential run-time errors and mark them in the code so you can fix them. However, there may still be some problems that the migration assistant does not detect those problems will become apparent only when the upgraded application runs and is thoroughly tested. The original application test cases and design documentation, if you have them, will be extremely...

Divide and Conquer

As with managing most big tasks, a good approach is the classic divide-and-conquer strategy. There are two ways to apply this concept to your upgrade project. The first way is to delegate the work based on projects or files. Assign individual project or source code files to your developers and have them focus on getting them to compile first. As previously mentioned, the assessment tool available for download from the community site for this guide, as discussed in the Feedback and Support...

Soap

While it is helpful to have some understanding of the infrastructure that underlies XML Web services, COM makes it easy to create and use them. Any COM application can be exposed as an XML Web service. Clients can then make remote calls to the methods in the default interfaces of the application's configured components. You can use the Component Services administrative tool to create an IIS virtual root directory that calls the component methods by using SOAP. You do not need to do any special...

Handling Changes to Property Pages

Visual Basic User Control

Visual Basic 6.0 property pages allow you to work around the limitations of the Visual Basic Property Browser. For example, you can use property pages to give users a way to add a collection of colors to a color list user control. In the property page, you would write code that manages the collection, something beyond the capabilities of the Visual Basic 6.0 Property Browser. In contrast, the Visual Basic .NET Property Browser can be used to edit any .NET variable type or class. Property pages...

SelfUpdate and ClickOnce

ClickOnce is a new application deployment technology that makes deploying a Windows Forms application as easy as deploying a Web application. This technology is available in the .NET Framework 2.0, which is included in Visual Studio 2005. With ClickOnce, running a Windows Forms application is as simple as clicking a link on a Web page. To deploy or update an application, administrators have to only update files on a server there is no need to individually touch every client. ClickOnce...

Completing the Upgrade with Manual Changes

After the upgrade wizard is applied to a Visual Basic 6.0 project resulting in Visual Basic .NET code, it is often be necessary to make adjustments to the upgraded code to make it run in the new environment. This section discusses some of the changes you may need to make. The first step in this process is to make the application compile in Visual Studio .NET. Before the application is compiled, you should review the project references to ensure all necessary references are present and correct....

Handling Changes to the MousePointer and Mouselcon Properties

In Visual Basic 6.0, you can use the MousePointer and MouseIcon properties to display a custom icon, cursor, or any one of a variety of predefined mouse pointers. Changing the mouse pointer gives you a way to inform the user of a variety of activities or possible activities. For example, it can inform the user that long background tasks are processing, that a control or window can be resized, or that a particular control does not support drag-and-drop operations. Using custom icons or mouse...

More Information Vkw

For more information about parameterized default properties in Visual Basic .NET, see Default Property Changes in Visual Basic in Visual Basic Language Concepts on MSDN vaconDefaultProperties.asp. For more information about the new collections available in Visual Basic .NET, see System.Collections Namespace in the .NET Framework Class Library on MSDN frlrfsystemcollections.asp. For more information about creating and registering Visual Basic 6.0 add-ins, see Creating a Basic Add-In on MSDN...

More Information Iad

A complete discussion about object-oriented design and development techniques is beyond the scope of this guide. For more information about object-oriented design, see Object-Oriented Programming in Visual Basic on MSDN vbconprogrammingwithobjects.asp. For more information about interfaces, see Interfaces in Visual Basic .NET on MSDN vaconinterfaces.asp. For more information about design patterns, see Microsoft Patterns on MSDN MSpatterns.asp. For a complete list of all the Windows API...

Test Strategy Based on the Waterfall Methodology

One possible testing strategy is based on the waterfall development methodology. In this strategy, after a single project of the entire application is upgraded, the upgraded project is unit tested. Then after all projects of the application are upgraded, all the upgraded projects components are integrated to get a working version of the application, which is then system tested for functional equivalence. This test strategy is illustrated in Figure 21.1. After all projects have been upgraded and...

COM Object Constructor Strings

COM object constructor strings are initialization strings that are administratively specified for a component. These object constructor strings can be used to write a single component with a degree of generality that allows it to be later customized for a particular task in other words, it allows you to create parameterized object constructors. Visual Basic 6.0 developers can use this COM feature by implementing the IObjectConstruct and IObjectConstructString interfaces. In Visual Basic .NET,...

Handling Changes to the PopupMenu Method

One of the most frequently used features of Visual Basic 6.0 Menu controls is the PopupMenu method, which displays a pop-up menu on an MDIForm or Form object. The pop-up menu can be displayed at the current mouse location or specified coordinates. Usually, this method is used in combination with mouse events. The following code example displays a pop-up menu at the cursor location when the user right-clicks a form. This example assumes the existence of a form that includes a Menu control named...

Handling of Unsupported Features

The upgrade wizard does not upgrade all the language features and technologies of Visual Basic 6.0 to Visual Basic.NET because some of these language features and technologies are not supported in .NET. The Visual Basic 6.0 features that are not upgraded by the upgrade wizard have to be manually upgraded. The manual effort that would be required to achieve functional equivalence for FMStocks 2000 after the automated upgrade would have been a difficult task if not for the assessment tool. The...

Using the Assessment Tool

The assessment tool that accompanies this guide generates two Microsoft Excel 2003 files. This first file is named MainReport.xls and contains a high level look at the results of the assessment. When you first open the file, you will see a page like the one illustrated in Figure 3.1. From the page illustrated in Figure 3.2, you can access the rest of the report in an ordered fashion. The first thing to notice is that this report contains a link to the second report, which is in a file named...

Changes to AddressOf Functionality

Certain Windows API functions, such as EnumFontsFamilies, require a pointer to a callback function. When you call the API function, Windows invokes the callback function that you provided. In the case of EnumFontsFamilies, Windows will call the function for each available font. Visual Basic 6.0 allows you to declare Windows API functions that take callback function pointers by declaring the function pointer parameter as Long, to represent a 32-bit pointer. Your code calls the API function and...

Upgrading the App Object

The App object in Visual Basic 6.0 is a global object that is used to set or retrieve information about the application. There is no direct equivalent for the App object in Visual Basic .NET however, most of the properties can be mapped to equivalent properties in the Microsoft .NET Framework. For example, the App object's version information properties are replaced by assembly attributes in Visual Basic .NET. In Visual Basic 6.0, you can set the version information by using the Project...

OLE Automation Call Synchronization

The Visual Basic 6.0 App object provides a group of properties that can be used to specify parameters for the interaction and synchronization with an OLE Automation server during the invocation of one of its methods. The first set of properties is related to the time that the application will retry a failed automation call request. After the specified time elapses, a customizable dialog box automatically displays in the application. This dialog box informs the user about the busy state of the...

Custom Marshaling

Assumptions or dependences about the internal characteristics of a data type can lead to the need for custom marshaling. Characteristics that are commonly taken for granted are internal representation, element size, and element position. When upgrading a part of a Visual Basic 6.0 application that depends on a piece of code that has special assumptions about a data type, it may be necessary to make the two pieces of code interact through .NET interoperability. In this type of scenario, the part...

Handling Changes to the OLE Container Control

The OLE Container control is used to dynamically add objects to a form at run time. For example, you can use an OLE Container to create a control that contains an embedded Microsoft Word document, create a control that contains a linked Word document, or bind to an OLE object in a database. Visual Basic .NET does not support the OLE Container control. As a result, the upgrade wizard is unable to upgrade an OLE Container control. Instead, it replaces the control with a red label to highlight the...

Upgrading Remote Data Objects RDO

This section covers issues that are specific for the upgrade of RDO technology to ADO. Applications that fall into this scenario have projects that reference the Microsoft Remote Data Objects. In them, at least one form contains the Remote Data Control for data binding and at least one control in the form uses data binding with Remote Data Control that uses the properties, DataSource and DataField . After you upgrade an application like this, the Remote Data Control appears to be upgraded....

To make the project and EXE application with two buttons

1. Use the following code to subscribe to the event. 2. Use the following code to test the event. 3. Use the following code to add to the project references to EventComponent, PublisherComponent, COM Services Type Library, and COM Admin Type Library. Implements EventComponent.EventClass Public Sub Update name As String Dim COM As Object Set COM COM.UpdateContact name End Sub Dim subscriptions As ICatalogCollection Dim comAdm As COMAdmin.COMAdminCatalog Set comAdm New COMAdmin.COMAdminCatalog...

Using the ASP to ASPNET Migration Assistant

You can use the ASP to ASP.NET Migration Assistant as a wizard through the Visual Studio .NET IDE or as a command-line tool. The next sections describe each of these approaches. To convert your ASP applications using Visual Studio .NET, point to Open on the File menu, and then click Convert. Next, click ASP to ASP.NET Migration Assistant from the list of available converters. If you have a solution open in Visual Studio .NET, you can click Add to current solution to add the result to your...

Command Line Registration

As previously stated, you must register your wrapper component within the system after you create it so that it is globally accessible to all of your Visual Basic 6.0 applications. The process for registering a component from within the Visual Studio .NET IDE was shown in the previous section. However, an assembly can also be registered at a Windows command line by using the Assembly Registration tool regasm.exe that is distributed with the .NET Framework. The procedure for this approach is...

Dealing with Changes to TypeOf

In Visual Basic 6.0, the TypeOf clause can check an object's type at run time. This clause is used in a decision statement that is, If to select a course of action based on the type of an object. The clause evaluates to True when the object is of the specified type otherwise, it evaluates to False. Visual Basic .NET supports the TypeOf keyword, but its behavior has changed. There are two major changes 1. In Visual Basic 6.0, user-defined types are considered object types for use in the TypeOf...

Methodology Overview

It is important to understand the concept of effort in the upgrade context. The effort of each task is expressed in hours that correspond to normalized time, that is, it corresponds with the time that the task would take if it was executed using average resources. If there is a highly experienced programmer in charge of that task, it will be finished in less time. In addition to average resources provided by default, the Effort Estimation report includes parameters such as junior developer,...

Visual Basic 60 Objects

This section explains how the upgrade wizard upgrades forms and visual components. It also summarizes the similarities and differences between Visual Basic 6.0 graphical controls and their .NET equivalents. The upgrade wizard upgrades Visual Basic 6.0 forms files with the file name extension .frm to Windows Forms, the .NET Framework's form development system, which uses classes in the System.Windows.Forms.Form namespace Upgraded form files are saved with the file name extension .vb, like other...

COM Transactions

In Visual Basic 6.0, you can use the MTSTransactionMode property to set the trans-actional behavior of a user class. This property is only used by components that are running in the Microsoft Transaction Server, and has no effect if the component is run outside of the MTS. In Visual Basic .NET, developers can use System.EnterpriseServices namespace to get transactional functionality for their .NET classes. To be treated as a transactional class, a Visual Basic .NET class should inherit from...

FMStocks 2000 Assessment and Analysis

The main objectives for upgrading FMStocks were to achieve functional equivalence and to accelerate the upgrade process. To achieve functional equivalence, an analysis of the functionality of the Visual Basic 6.0 version of the FMStocks was required. To fulfill the second objective of accelerating the upgrade process, apart from the automated upgrade, a concrete upgrade strategy and plan that included the estimates, tasks, risks and issues involved in the upgrade were required. To make a...

To complete the upgrade 1

1. Add the EnterpriseServices reference to the project and a corresponding Imports statement to the class. 2. Change the class to inherit from the ServicedComponent class. Inherits ServicedComponent 3. Delete all COMSVCSLib references from the project. 4. Replace the Visual Basic 6.0 SecurityCallContext object with the .NET 5. Replace the Visual Basic 6.0 GetSecurityCallContext method with the .NET static method SecurityCallContext.CurrentCall. 6. Sign the component with a strong name by adding...

To create a functionally equivalent component

1. Add the EnterpriseServices reference to the project and a corresponding Imports statement to the class. 2. Change the class to inherit from the ServicedComponent class. Inherits ServicedComponent 3. Sign the component with a strong name by adding the corresponding AssemblyKeyFile attribute to the AssemblyInfo.vb file. Generate the key file with the following command. For more information about strong names, see the Using COM in Visual Basic .NET section earlier in this chapter. 5. Remove all...

Upgrading the Screen Object

Similar to the App object, the Visual Basic 6.0 Screen object provides properties and methods for retrieving, and in some cases setting, global application properties. Using the Screen object, you can set the MousePointer property to display an hourglass pointer when a modal form is visible or retrieve the active control or active form of the application. Although there is not a direct equivalent for the Screen object in Visual Basic .NET, most of the properties can be mapped to equivalent...

Upgrading Data Environment

Data Environment is a Visual Basic 6.0 feature that provides an interactive, design time environment for creating programmatic, run-time data access. Visual Basic .NET provides an even more powerful environment for building database applications, but because the underlying data access library is conceptually different Visual Basic .NET uses ADO.NET while Visual Basic 6.0 uses ADO , there is no direct mapping between Data Environment in Visual Basic 6.0 and data access features in Visual Basic...

FMStocksNET Setup

The final functionally equivalent code produced during this case study can be found in FMStocks_NET. You can obtain this code from the GotDotNet community site. The file is FMStocks_NET.msi. This file installs FMStocks_NET, which is the functionally equivalent working version of FMStocks 2000. When the contents of this file are installed, the installation folder is C Program Files FMStocks_NET. The assessment tool reports and the final functionally equivalent code are installed so that you can...

Using Configuration Files

You can use configuration files to configure .NET applications without recompiling them. These configuration files help you to store application variables and configuration values, just as you could with earlier versions of Visual Basic by using .ini files and later, registry settings . In addition, Visual Basic .NET configuration files allow you to keep properties for visual components so they can be dynamically changed by just editing a text file. Configuration files can contain different...

Upgrading Addins

You can use the Visual Basic extensibility object model to ease development through add-ins. Add-ins are tools that you create programmatically using objects and collections in the extensibility model to customize and extend the Visual Basic integrated development environment IDE . In a sense, add-ins snap on to the Visual Basic IDE. Regardless of how they are created, the primary goal of an add-in is to enable you to automate something in the development environment that is difficult, tedious,...

Determine All Dependencies

When one application component uses another component, the first component is said to be dependant on the second. There are different types of usage that require different ways to identify such dependencies. Usage can appear in the form of access to a class member, invocation of a method, declaration of a variable with a particular type or the inclusion of an embedded control. Dependencies also exist at the project level and can be established through project references. The dependency...