Working with the Windows API

The Windows API is the foundation that every Windows application is built on. Visual Basic applications are no exception. Visual Basic, through the language and forms package, abstracts the Windows API to a set of easy-to-use statements, components, and controls. In many cases, you can build a Visual Basic application without having to directly call a Windows API function. However, because the Visual Basic language and forms packages do not represent every Windows API function available, Visual...

Custom Data Access Components

Custom data access components are those components that encapsulate data access technologies such as ADO, DAO, or RDO inside a DLL or an OCX that your application uses. These components may have been developed internally in a specific language, or they may have been purchased from another company with or without the source code. There are various alternatives for upgrading applications that use custom data access components. The approach that you take will depend on whether you have access to...

Using Identities and Authentication

Security is one of the most important features to consider when you build .NET applications. Application developers must consider several situations that may occur when an application is used in a production environment. Security attacks are very common, and nobody wants to have an unsecured application running in their organization. The .NET Framework provides classes that help to manage security situations. They make it easy to implement role-based security in your application. Implementing...

Visual Basic 60 Language Elements

The upgrade wizard upgrades different Visual Basic 6.0 elements to Visual Basic .NET, as discussed in the next sections. The upgrade wizard automatically upgrades variable declarations to their equivalent.NET Framework types, following the Visual Basic .NET structure and taking into account the Visual Basic 6.0 declaration guidelines. For example, in this Visual Basic 6.0 code, a and b are implicitly declared with the Variant data type, and c is declared explicitly as a 16-bit integer. In...

Accessing NET Assemblies Directly from Visual Basic

The process for calling .NET assemblies from Visual Basic 6.0 is fairly straightforward. The general process is as follows 1. Determine the assembly you want to access. 2. Locate the assembly's type library. Note The assembly must be registered using the Assembly Registration utility (regasm.exe) to be accessed from COM clients. For more information about registering assemblies, see the Access Requirements section earlier in this chapter. 3. In your Visual Basic 6.0 application, add the...

More Information

For more information about upgrading performance, see Chapter 4, Architecture and Design Review of .NET Application for Performance and Scalability, of Improving .NET Application Performance and Scalability on MSDN scalenetchapt04.asp. For more information about design review for security enhancement, see Architecture and Design Review for Security on MSDN secmod78.asp. For information about recommended coding standards in your Visual Basic .NET code, see Program Structure and Code Conventions...

Dealing with Changes to Arrays

In Visual Basic 6.0, you can specify the starting index for arrays using the Option Base declaration or by specifying the index range in the array declaration. In Visual Basic .NET, all arrays have a starting index of 0. As a result, the Option Base 1 declaration is not supported, nor is specifying an array index range. Consider the following Visual Basic 6.0 array declarations. Option Base 1 Dim VariantArray(5) As Variant '5 elements (1-5) ' Specify the array index range in the array...

Performing Unit Testing White Box Testing

White box testing is testing based on analysis of the implementation details and the program logic of the component or application tested to identify potential failure scenarios. White box testing includes unit testing and profiling the upgraded application. Profiling will be explained later in this chapter. Unit testing involves testing a single component. The components of the upgraded application are unit tested to detect failure scenarios in loops, conditional constructs, and internal...

Code Quality Assessment

An important factor in determining whether to upgrade your application is the current quality of its code design and implementation. Detailed analysis of your application's source code will provide information on code quality, design complexity, and component dependencies. You can use the Visual Basic Upgrade Assessment Tool to help capture some of this information. For a complete description of the tool, see Chapter 3, Assessment and Analysis. The Visual Basic Upgrade Assessment Tool is...

Upgrading the Forms Collection

The Forms collection in Visual Basic 6.0 is a collection of all loaded forms in the project. The most common uses of the Forms collection are to determine whether a form is loaded, to iterate through the loaded forms, and to unload a form by name. Visual Basic .NET does not support the Forms collection, but as with the other objects discussed in this chapter, it does provide similar functionality. The following Visual Basic 6.0 example shows how to iterate through the Forms collection,...

Reviewing the Upgrade Wizard Report

As part of the preparation stage, it is important to perform a partial test upgrade of the application to determine or detect each of the following Upgrade process speed. The time consumed by the upgrade of a part of the application can provide an idea of the time required to upgrade the entire application. This information is useful for the upgrade procedure planning. System resources. The available system resources, especially the amount of system memory, can be evaluated using a part of the...

Passing User Defined Types to API Functions

When you pass a Visual Basic 6.0 user-defined type to an API function, Visual Basic passes a pointer to the memory that contains the user-defined type. The API function sees the members of the user-defined type in the same order that they were declared in Visual Basic. However, this is not the case for Visual Basic .NET. If you declare a user-defined type, the order of the members is not guaranteed to stay the same in the code. The common language runtime (CLR) may reorganize the members of a...

Handling Unsupported Features

The upgrade wizard automatically upgrades most of the language constructs and intrinsic components. It also supports third-party components and different types of Visual Basic 6.0 projects. However, there are still features that are not fully supported by the upgrade engine and require some level of manual work to be upgraded to Visual Basic .NET. The Visual Basic Upgrade Wizard Companion, available from ArtinSoft, supports many features that are not supported by the upgrade wizard. When an...

Missing Application Elements

After the initial upgrade preparation steps are complete, it is possible that some of the application components are not yet available on the computer where the automated upgrade is going to take place. After these components are identified, it will be necessary to correct the environment before the upgrade process can be restarted. These additional steps will consume time and resources that need to be accounted for. The assessment tool identifies missing application elements that can be...

Black Box Testing

In black box testing, the implementation details of the component or application to be tested are unknown. Black box testing simulates the end-user client experience and tests the response of the upgraded applications to end-user or client actions. The objectives of black box testing are To test for functional equivalence of the upgraded application with the original Visual Basic 6.0 version of the application. To test that the upgraded application has achieved the upgrade objectives. To test...

Upgrading the Printer Object

In Visual Basic 6.0, the Printer object enables applications to communicate with a system printer. The Printer object contains functions for printing text, lines, and images. However, the printing model in the .NET Framework is quite different from that in Visual Basic 6.0. The Printer object has become obsolete. Fortunately, the functionality of the Printer object can be achieved with the classes that are provided in the System.Drawing.Printing namespace, particularly the PrintDocument class....

Planning the Upgrade

The upgrade planning stage for FMStocks 2000 consisted of the following substages deciding the upgrade strategy, defining the upgrade order, and creating an upgrade schedule with estimates of cost and effort. The data from the assessment and analysis stage of FMStocks 2000 was the input for the upgrade planning stage of FMStocks 2000. The upgrade planning stage required approximately 4 work hours of effort. The upgrade strategy adopted for the FMStocks 2000 upgrade was the complete upgrade...

Converting Data Reports to Crystal Reports

Visual Basic 6.0 provides the Microsoft Data Report Designer, a versatile data report generator that features the ability to created banded hierarchical reports. Used in conjunction with a data source such as the Data Environment Designer, you can create reports from several different relational tables. In addition to creating printable reports, you can also export the report to HTML or text files. In Visual Basic .NET, the standard reporting tool is Crystal Reports. This tool allows the...

Upgrading References to Visual Basic 60 Enum Values

Upgrading code that refers to any predefined Visual Basic 6.0 enumerator values requires special care. The upgrade wizard may replace the enumerator reference with a new object in Visual Basic .NET that represents the same value, but it is not a simple enumerator value. The examples in this section demonstrate this. If you define a constant in Visual Basic 6.0 to represent a property on a Windows form or control, you may find that the code does not compile after you upgrade the project....

Preparing Your Code for the Migration Assistant

There are some actions that you can take to modify your code to help the migration assistant improve its automatic conversion and reduce the number of manual changes you have to make after upgrade. The most important of these changes are described in the next sections. Register All Referenced COM Components The first step is to analyze your code to identify all the COM components that your application uses. After compiling the list, ensure that all of the components are correctly installed and...

Dragand Drop 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...

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...

To complete the upgrade

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 Background Worker 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

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...

Self Update and Click Once

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...

Handling Changes to the Mouse Pointer 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...

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...

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

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 create a functionally equivalent component

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...

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...

Upgrading ADO Data Binding

Data binding is one of the most powerful uses of data access in Visual Basic 6.0. Essentially, using data binding allows a property of a control to bind to a specific field in a database. When the bound control property such as the text box's Text property is modified by the user of the control, the control notifies the database that the value has changed. It then requests that the relevant field of the current record be updated. This process takes place, and in return the database notifies the...

Catching NET Exceptions in Visual Basic

When HRESULT signals that an exception has been raised by the .NET assembly, the On Error clause is invoked in Visual Basic 6.0 if it has been declared and defined. The actual error condition can be examined by using the Visual Basic 6.0 intrinsic Err object and by inspecting its Description and Number properties. Note There is a well-defined mapping of common .NET exceptions to Visual Basic 6.0 error codes that can be used to determine the type of system error encountered. For more information...

Fixing Run Time Errors

After an application is upgraded, the most difficult errors to detect are those that can only be identified at run time. A high percentage of potential run-time errors are detected by the upgrade wizard. However, there may be problems that will be detected only after the upgraded application runs and is thoroughly tested. The original application test cases and design documentation is particularly important to identify such errors. The remainder of this section presents some common upgrade...

Handling Changes to DDE Functionality

At one time, Dynamic Data Exchange DDE was one of the few ways you could pass data between applications without using a shared file. Support for DDE in Visual Basic has been present since version 1. However, DDE has since been replaced by COM. With COM, you can share data and invoke methods between applications in a more efficient and scalable manner. Because most Windows-based applications that expose public data and methods do so by way of COM, DDE is not the primary way that you retrieve...

Upgrading the Controls Collection

To add and remove controls at run time, Visual Basic 6.0 provides the Controls collection. The Controls collection is a dynamic collection of controls on a form or container. Through this collection, it is possible to add and remove controls on a form or container at run time. For example, consider the following code that adds a Label dynamically to a form at run time. Set labelControl Me.Controls.Add VB.Label, labelControl labelControl.Visible True This code adds a Label to the form and makes...

Functions Obj Ptr Str Ptr and Var Ptr Are No Longer Supported

In Visual Basic 6.0, it is possible to obtain the 32-bit address of an object, a string, or a variable or user-defined value through the undocumented helper functions ObjPtr, StrPtr, and VarPtr, respectively. Visual Basic .NET does not support these functions, nor does it allow you to obtain the memory address for any type. At first, this may seem overly restrictive. However, the benefits of this restriction are significant. Leaving memory management to the CLR frees you from having to worry...

COM Shared Property Manager

The COM Shared Property Manager SPM can be used to manage shared transient state for objects. Global variables cannot be used in a distributed environment because of concurrency and name collision issues. The SPM eliminates name collisions by providing shared property groups, which establish unique namespaces for the shared properties they contain. It also implements locks and semaphores as synchronization mechanisms. On single processor servers with small numbers of clients, the Shared...