Chapter 5: Migrating Visual Basic 6.0 Applications to Visual Basic.NET


Visual Basic.NET (VB.NET) is an updated version of Visual Basic (VB) 6.0, which has retained or enhanced many features of the original language and added some new ones. The new features allow you to develop and deploy distributed desktop and Web applications easily. You can migrate applications developed in VB 6.0 to VB.NET.

This chapter describes the advantages of translating VB 6.0 code to VB.NET and explains the process of migration using a case study.

Advantages of Migrating from VB 6.0 to VB.NET

VB.NET offers several advantages over VB 6.0, such as object-oriented features, ease of developing and deploying Windows and Web applications, ability to develop Web services and mobile applications, improved security features, ability to access data using disconnected record sets, and backward compatibility.

Object-Oriented Features

VB 6.0 is object-aware, while VB.NET is an object-oriented language that supports object-oriented features, such as abstraction, encapsulation, inheritance, and polymorphism. VB 6.0 supports abstraction and encapsulation but does not support inheritance, polymorphism, overloading and overriding methods, and the use of constructors.

Abstraction

A language that allows you to create classes from which you can instantiate objects supports abstraction. You can create a class, define an abstraction, and then create specific instances of the class, with each instance possessing its attribute values. VB 6.0 uses class modules to create classes, while VB.NET uses the Class keyword to define classes. For example, the following syntax defines a class in VB.NET:

 Public Class Car ‘Class definition ... End Class 

Encapsulation

Both VB 6.0 and VB.NET support encapsulation by enabling you to create classes that hide the complexity of implementing classes. The classes expose their functionality through properties and methods. For example, a class can contain a method that calculates the square root of an integer. You need to expose the method so that other classes can access the functionality of that method, which hides a complex algorithm to calculate the square root.

Inheritance

Unlike VB 6.0, VB.NET supports inheritance and overriding. You can create a class that receives or inherits the characteristics of another class. Overriding allows a derived class to extend the behavior of its members in its base class. As a result, you can have base classes that provide a default implementation for a particular method. The derived classes can then create their own implementation of that behavior. Listing 5-1 shows how VB.NET implements inheritance and overriding:

Listing 5-1: Inheritance Between Two Classes

start example
 Public Class Vehicle Dim num_of_wheels as Integer Dim num_of_seats as Integer Dim motored as Boolean Public Sub OnAccelerate() ‘Code for this method End Sub Public Sub OnBrake() ‘Code for this method End Sub End Class Public Class Car Inherits Vehicle Dim model_no as String Public Overrides Sub OnAccelerate() ‘Code for this method End Sub Public Overrides Sub OnBrake() ‘Code for this method End Sub End Class 
end example

In the above listing, the Car class inherits the features of the generic class, Vehicle. The features include variables, such as num_of_wheels, num_of_seats, and motored; and methods, such as OnAccelerate() and OnBrake(). The derived class, Car, adds the model number of the car to the features inherited from the Vehicle class and writes its implementation of the inherited methods.

Polymorphism

You can use method overloading to achieve polymorphism in VB.NET. Method overloading allows you to create multiple methods with the same name that function differently in different circumstances. The overloaded methods must have different argument signatures, which means that the number, type, or order of the arguments of these methods must differ. If two methods differ only in their return types, they are not overloaded. Listing 5-2 shows how VB.NET implements overloading:

Listing 5-2: Implementing Method Overloading

start example
 Public Overloads Sub Display(ByVal message as String) MsgBox(message) End Sub Public Overloads Sub Display(ByVal num as Integer) MsgBox(num) End Sub 
end example

In the above listing, two methods have the same name, Display. One method displays a string and the other displays an integer. As a result, you can call the Display method with an integer argument, such as Display (53), and a string argument, such as Display ("Hello World"). You need not remember the names of different methods that perform similar functionality and differ only in the type of data that you pass to these methods and the data that these methods return.

VB 6.0 does not allow overloading. To overcome this limitation, you need to create separate methods with different names in VB 6.0.

Note

To learn more about object-oriented design, see the Object-Oriented Design ReferencePoint.

Ease of Web-Application Development

You can use VB 6.0 to create Dynamic Hypertext Markup Language (DHTML) and Internet Information Server (IIS) applications. In DHTML and IIS applications, you build the user interface using DHTML and HTML, and build request-processing and event-handling logic using VB 6.0 code. A DHTML application resides on the browser and responds to browser events that end-user actions generate. An IIS application resides on the Web server and processes requests from the client browser. DHTML applications run on an intranet because they depend on the browser or the operating system. IIS applications are platform-neutral and run on both intranets and the Internet.

The .NET Framework provides a new forms package, called Web Forms, to develop Web applications. The Web Forms package simplifies the task of creating VB.NET Web applications, which can run on different browsers and platforms on the computers of end users. A Web form has two parts:

  • Presentation logic: Consists of user interface elements, such as buttons, text boxes, and list boxes. You can drag the elements from the toolbox to forms. The visual part of a Web application resides in a .aspx file.

  • Business logic: Consists of form code, which resides in a .aspx.vb file. The Web Forms package provides a set of controls along with their properties, methods, and events. You can use the controls to write the business logic behind the user interface of Web applications.

The advantages of creating Web applications in VB.NET, compared with creating them in VB 6.0, are availability of server-side controls and reduced code.

Server-Side Controls

VB.NET uses a set of server-side controls that render in the markup language appropriate to the client browser from which the request originated. Server-side controls, such as Label, TextBox, ListBox, and AdRotator, either extend the functionality of HTML controls or define a new functionality. These controls are automatically processed at the server side. By contrast, when developing IIS applications in VB 6.0, you use HTML controls with the "runat=server" attribute-value pair specified explicitly in code to make the server respond to the events of the controls.

Server-side controls include a set of Field Validator controls that validate the data an end user enters using the client browser, before submitting the data to the back-end server. This saves time and network bandwidth. Various types of Field Validator controls, such as RangeValidator and CompareValidator, are available. RangeValidator validates a range of data and CompareValidator compares the data of two controls in a form.

Reduced Code

The data-binding capability of server-side controls in VB.NET reduces the amount of code you need to write in Web applications. For example, you can retrieve the value of a TextBox control by using the Text property of that control. You need not explicitly pass data from one form to another because data is directly available to the server and you can manipulate the data in the code.

In VB 6.0, you need to use a QueryString to pass the value of a textbox from one form to another. QueryString gets appended to the URL of the requested page and contains all the data you need to pass to the requested page.

Development of Web Services

The .NET Framework provides an infrastructure that enables you to create eXtensible Markup Language (XML)-based Web services using .NET languages, such as VB.NET. You can use the XML-based Web services to exchange data among end users on the Web, regardless of the platform they use. In addition, VB.NET allows you to write code to use the services that other hosts offer on the Web. For example, some Web sites offer public services, such as search and spell check, which you can use in VB.NET applications.

Each Web service accomplishes a limited set of tasks but can collaborate with other Web services to perform complex operations. For example, you can create a small Web service that converts one currency to another, or you can create a complex business system that records the inventory at all a company's branch offices.

Note

To learn more about Web services, see the "Web Service" What Does it Really Serve? ReferencePoint, and Chapter 9 of the book, Components and Web Services in VB.NET.

Managed Code

Compared with VB 6.0, code written using VB.NET is bug-free because it is managed.

Note

Code that targets the Common Language Runtime (CLR) for its execution is managed code, which compiles into Microsoft Intermediate Language (MSIL) and then executes under the control of the CLR. To learn more about CLR and managed code, see Chapter 1.

CLR provides a common set of low-level services to all managed objects, regardless of the language you use to create the objects. CLR services include strict type checking, automatic garbage collection, built-in security, and advanced compilation techniques. In addition, managed code uses the ability of VB.NET to handle structured exceptions. As a result, managed code is secure, maintainable, and less prone to errors than unmanaged code.

Strict Type Checking

The .NET Framework provides Common Type System (CTS), which prevents your application from casting a type into an incompatible type. CTS also allows you to avoid passing wrong types of arguments to a procedure. This ensures type safety and reduces programming errors in your application. For example, the following code is in VB 6.0:

 Public Sub procedureA (ByVal someInteger As Integer, ByVal someString As String) Msgbox someInteger Msgbox someString  End Sub 

If you call this method as procedure A(12.25, 23), a type error is not generated. This is because 12.25 and 23 are converted to integer 12 and string 23, respectively. The same call in VB.NET, with the Option Strict On statement, generates an error due to the difference in the signatures of the method definition and the method call.

Automatic Garbage Collection

CLR provides an automatic garbage-collection feature that frees the resources that your VB.NET application no longer uses. VB 6.0 uses reference counts to manage object lifetimes.

CLR creates objects on a garbage-collected heap and then removes the nonreferenced objects from the memory at an indeterminate time in the future. Some of the key features of automatic garbage allocation are:

  • Speedy allocation: Allocates memory rapidly because only a pointer and not a linked list of memory chunks need to be managed by the garbage collector.

  • Consecutive allocation: Allocates continuous chunks of memory and not scattered blocks. This enhances performance.

  • Simplicity of code: Makes code smaller and simpler than in VB 6.0 by automatically freeing unused memory. You need not write explicit code for memory management.

  • No leakage of memory: Prevents your application from accidentally referencing freed memory.

  • No run-time resource management: Saves time by eliminating the need for the runtime to maintain reference counts for strings, dynamic arrays, objects, and interfaces. In VB.NET, the garbage collector can search for all the active references to an allocated object in a short time.

Advanced Compilation

VB.NET provides a real-time background compiler that informs you about errors as they occur. Unlike VB 6.0, VB.NET allows you to fix the errors before you explicitly compile the code.

Figure 5-1 shows how the real-time background compiler works:

click to expand: this figure shows the code window of a vb.net application.
Figure 5-1: The Real-Time Background Compiler in VB.NET

The code in the figure shows the ConvertInteger() subroutine, which declares an integer variable, sampleIntegerVariable, and initializes it to 20. The code then declares another variable, sampleType, of the undefined type, abcd. When the subroutine converts the sampleIntegerVariable variable into the unknown type, abcd, the real-time background compiler underlines abcd in blue to indicate that it is the source of a potential error. This helps detect the error before you compile the code explicitly.

CLR includes a Just-In-Time (JIT) compiler called jitter. All .NET applications compile to MSIL, after which the jitter converts MSIL to binary code. This binary code is native to the computer on which the application executes, and is optimized for the hardware and the platform. The jitter converts only the currently called methods, and not the entire MSIL, to binary code. After the jitter translates a method to native code, the jitter caches the native code in memory. Subsequent calls to the same method use the cached binary version of the method. This conserves system resources and enhances application performance.

Structured Exception Handling

The .NET Framework uses exceptions that encapsulate run-time errors. VB 6.0 provides the On Error Goto structure to handle errors where you need to transfer control to a specific part of code each time an error occurs. In VB.NET, instead of the On Error Goto structure, you can use the try-catch-finally-end try block in which errors are thrown and caught within one or more catch blocks. You can place code that may raise errors during execution in the try block. The catch block contains error handlers that are called if errors occur. After the error handler in the catch block completes executing, control transfers to the statement after the end try statement. The finally block contains statements that should be executed whether or not an exception is raised. The statements include the ones that release the resources that the program occupies, such as memory or a connection to the database. The end try statement marks the end of the exception-handling structure.

Listing 5-3 shows how to use the try-catch-finally-end try block in a program:

Listing 5-3: Exception Handling in VB.NET

start example
 Public Sub Division_Addition() Dim num1 as Integer = 10 Dim num2 as Integer = 0 Dim quotient as Single = 0  Dim result as Single Try quotient = num1 / num2 Catch ex as Exception MsgBox("Division by zero error", MsgBoxStyle.OKOnly, "Error") quotient = 0 Finally result = quotient + 25 End Try MsgBox("The result is " & result, MsgBoxStyle.OKOnly, "Result") End Sub 
end example

The above listing shows a subroutine, Division_Addition(), which divides an integer, num1, by another integer, num2. The statement that performs the division resides in a try block. When code executes, VB.NET raises a division-by-zero exception because the value of num2 is 0. The catch block catches this exception and shows an error message to the end user. In addition, the catch block resets the value of the quotient to 0. After the catch block completes execution, control is transferred to the finally block, which adds 25 to the quotient and stores the sum in the result variable. A message box then displays the result to the end user. If you initialize num2 to a nonzero value, an exception is not raised and the catch block is skipped. In this case, only the finally block is executed and the result is displayed.

Built-In Security

VB.NET helps develop secure applications either by allowing you to explicitly code for security or by using the built-in security features that the CLR provides. The runtime decides whether or not to execute a portion of code and whether to accept or reject a code’s request for access to a system resource. The various options available in the security model that the .NET Framework provides are:

  • Role-based security: Identifies end users and their roles for authentication and authorization. You can assign different permissions to different people, depending on the group to which they belong. The permissions include reading from a file, writing to a file, and executing a script file. Two concepts govern role-based security, Identity and Principal. Identity represents the end users who execute code. Identity can be a Windows account or a custom identity. Principal encapsulates both the identity of the user and the roles to which the end user belongs. The roles include memberships and security contexts.

  • Code access security: Controls the resources that code can access and the operations that code can perform. For example, you can deny database access to a portion of code. This protects computer systems from malicious mobile code, allows code from unknown origins to run with protection, and prevents trusted code from breaching security, accidentally or otherwise. Two concepts govern code access security, permissions and evidence. Permissions determine whether you want to allow the code to perform a specific operation, such as access to a resource, or not. Evidence means the different levels of trust assigned to all running code in the .NET Framework. This enables you to safely run semi-trusted code, subject to the restrictions that the administrator specifies.

  • Cryptography: Includes encryption, digital signatures, hashing, and random number generation. Encryption-decryption algorithms help communicate data securely. The algorithms allow you to encrypt data before sending it and decrypt the received encrypted data.

VB 6.0 applications implicitly support role-based security. To implement any other security feature, you need to write explicit code. VB.NET implicitly supports role-based and code access security. For example, you can set the permission for a file named XYZ.XML as read-only. If you build a VB.NET application that writes to the XYZ.XML file, the runtime compares the permission the application has requested with the permissions allowed on XYZ.XML. If there is a mismatch, the runtime raises a security exception. As a result, you are denied access to the XYZ.XML file.

Note

To learn more about built-in security, see the .NET Framework Security ReferencePoint.

Ease of Deployment

VB.NET eliminates the deployment issues that you face in VB 6.0 applications. For example, to deploy an application in VB 6.0, you need to register the components with registry files and then use them.

Note

VB 6.0 uses registry entries for Program Identifiers (ProgIDs), Class Identifiers (CLSIDs), Interface Identifiers (IIDs), and type libraries.

VB.NET does not need to interact with the system registry. In VB.NET, you can deploy an application on a client computer by copying the entire directory tree that contains your application and the bin directory under it from the source computer to the target computer. This eliminates the need for complex setup scripts to resolve types and search for loadable modules at runtime.

VB.NET also helps overcome the problems associated with component versioning in VB 6.0. For example, in VB 6.0, you can deploy a Dynamic Link Library (DLL) on a computer only once. If you install a new version of a DLL, the new version overwrites the older version. Applications that access the older version of the DLL will not be able to access that version because that is overwritten by the newly installed DLL. As a result, it is difficult to maintain compatibility between multiple versions of an application on a computer. VB.NET supports side-by-side versioning, which allows you to deploy and manage infinite number of versions of an application on the same computer without creating version conflicts. Because multiple versions of the same component can exist on one computer in VB.NET, an application can use a specific version of the component with which it was originally compiled. As a result, you can deploy multiple versions of the same DLL to enable both the earlier and the new applications to use the DLL to run successfully.

Caution

The side-by-side versioning support that VB.NET provides is available only when you deploy your assembly as a shared assembly.

Note

To learn more about assemblies, see Chapter 1, and the Understanding Assemblies ReferencePoint.

In addition, VB.NET provides the auto-downloading feature for easy deployment of Windows-based applications. The two types of auto-download applications are:

  • No-touch deployment: Automatically downloads .exe files and all related DLLs to the client computer, without changing anything on the client computer. This means that subsequent deployments of applications that use a different version of the same DLL as your application cannot break your application. No-touch deployment makes it easy to run many applications on a system and ensure that they all work together.

  • Auto-update applications: Automatically check for updates, and sometimes automatically download and install the updates to keep the applications running with the most recent versions of the DLLs after deployment. Some examples of these systems are Messenger, Windows Update, and Office Update.

Enhanced Windows-Based Applications

The .NET Framework provides a new forms package, called Windows Forms, which helps you create enhanced Windows applications easily. The Windows Forms package implements as a set of .NET classes that are a part of the framework and are available to all .NET-compliant languages. Windows Forms are code generators that generate managed classes for different GUI elements, such as forms, text boxes, or buttons. The Windows Forms package includes several features, such as anchoring, docking, in-place menu editing, visual tab-order editing, and visual inheritance, to build enhanced Windows-based applications.

Anchoring and Docking

Anchoring and docking eliminate the need to write complex code for resizing. Anchoring fixes the position of a control, such as a text box, relative to the position of the parent container, such as a group box or form. This prevents the displacement of child controls when you resize the parent container. You can set the edges of the child control, which are anchored to the edges of the parent container. By default, all controls are anchored to the top and left edges of their parent container.

Figure 5-2 shows the original window in which only some of the child controls are anchored to the parent container:

click to expand: this figure shows a form containing a picture box, label, text box, and button. this form displays in the same format as you designed it in design view.
Figure 5-2: The Original Window with Anchored Controls

Figure 5-3 shows the effect of resizing the window in which only some of the child controls are anchored to the parent container:

click to expand: this figure shows the effect of resizing the previous window. the resized window shows that the picture box and the text box are displaced from their original positions, while the locations of the label and the button have not changed.
Figure 5-3: The Resized Window with Anchored Controls

This is because the label and the button are anchored to the top and left edges of the container form. As a result, resizing the form does not change the respective distances of the label and the button from the top and left edges of the container form. Because the picture box and the text box are not anchored to any edge of the container form, they are displaced when you resize the window.

Docking is the process in which an edge of the child control, such as a picture box, adheres to the corresponding edge of the parent container, such as a form; or the child control fills the entire area of the parent container. You can set the edges of the parent container to which the child control is docked. When you resize the parent container, the docked edge of the control also resizes to match the size of its parent container.

Figure 5-4 shows the original window in which the picture box is docked to the top edge of the container form:

this figure shows how the picture box is docked to the top edge of the container form.
Figure 5-4: The Original Window with Docked Controls

Figure 5-5 shows the effect of resizing the window in which the picture box is docked to the top edge of the container form:

click to expand: this figure shows the effect of resizing the previous window. notice that when you resize the window, the picture box also resizes to match the top edge of the container form. this is because the picture box is docked to the top edge of the container form.
Figure 5-5: The Resized Window with Docked Controls

In-Place Menu Editing

Unlike VB 6.0, where you need to create menus using the Menu Editor, VB.NET helps you do so by using in-place menu editing. This feature allows you to directly type the name of the menu item where needed on the menu bar. You can scroll down the same menu using the down arrow key and move to another menu or submenu using the right arrow key.

Figure 5-6 shows in-place menu editing in VB.NET applications:

this figure shows how to create menus in vb.net applications. you create menus in the what you see is what you get manner.
Figure 5-6: In-Place Menu Editing

Visual Tab-Order Editor

VB.NET provides the new tab-order editing feature. Using this feature, you need not use the Properties window to set the tab order of components on the form. You can use the visual view of controls to click each control in the desired tab order. In this way, you can set how tabs navigate through the controls.

Figure 5-7 shows tab-order editor in VB.NET:

this figure shows the tab order of different controls on the form. you have set the tab order using the tab-order editor.
Figure 5-7: The Tab-Order Editor

Visual Inheritance

Visual inheritance in the Windows Forms package allows you to design new forms and controls, in addition to classes. This is because forms and controls are classes with a visual interface. Visual inheritance reduces application development time and costs, and provides consistent layouts.

You can design a form template that includes all the common controls with their respective portions of code. .NET applications can derive new forms from this template and override the functionality, as required. The features of visual inheritance are:

  • Common menu structure: Creates forms with the same menu structure.

  • Common user controls: Creates forms with a common set of controls, such as buttons and images that are common to all the forms.

  • Common behavior: Creates forms that provide a common functionality. The derived forms can override this functionality, if required. This common functionality is code behind the controls on the template form.

For example, a company needs to create an application with 100 forms, each with the same look and feel. The company wants its logo to appear in the top-left corner of all forms. In addition to the logo, the company needs a common menu structure for all forms. All forms should exhibit the same functionality when users click different menu items. To achieve this, you can create a template, which contains the logo and the menu and write code for different menu items. Figure 5-8 shows the form template:

click to expand: this figure shows the base form that contains the company logo in the top-left corner of the form and the menu structure required for all the forms.
Figure 5-8: The Base Form

The company can create another form that looks like the form in Figure 5-9:

click to expand: this figure shows the new form that contains the logo, the menu structure, and company information.
Figure 5-9: The Desired Form

Instead of designing the form again and rewriting code, the company can visually inherit the template form and add other controls to it to obtain the desired form. The inherited form looks like the form in Figure 5-10:

click to expand: this figure shows the form derived from the template form. the picture box in the inherited form contains small arrows in the top-left corner to indicate that it is inherited.
Figure 5-10: The Inherited Form

Flexible Data Access

VB.NET provides flexible and scalable access to data residing in multiple data sources, such as databases and files. It supports both the connection-oriented data access that ActiveX Data Objects (ADO) provides and the XML-based disconnected data access that ADO.NET provides. VB 6.0 supports only connection-oriented access to data sources that ADO provides.

Note

To learn more about ADO.NET, see Chapter 11 of the book "Creating Components and Web Services in VB_NET".

Disconnected Data Access

VB.NET provides disconnected access to data using the DataSet object of ADO.NET. This object is a disconnected and locally cached representation of data retrieved from a data source. You can query, manipulate, or update data in a DataSet object, without depending on the database. You can connect to the database later and update the data in the database from the DataSet object. This means that when an application needs to access data from a database, it opens a connection to the database. This connection remains open until the application request finishes executing. In contrast, VB 6.0 supports the connected data access that ADO provides, in which the connection to a database remains open throughout the lifetime of the application. This approach has several disadvantages:

  • Overhead of maintaining several concurrent connections and wastage of system resources.

  • Scalability problems that occur when the number of open connections to a database is more than system capacity. This reduces the performance of the system.

  • Security issues caused by several concurrent connections to a database. As a result, the database is more susceptible to misuse and corruption.

To understand the advantage of disconnected data access over a connected recordset, say, for example, you have a query tracker application in VB 6.0 that allows customer support executives to view, answer, and update the status of queries directed to them. To retrieve the queries meant for a particular executive, the application creates a connection to the database and retrieves the queries in a connected recordset object that ADO provides. The connection to the database remains open until the executive logs off from the application. This connection blocks system resources. If 100 executives log on to the application, 100 different recordset objects use the same connection, reducing performance of the application. To use disconnected data access in your VB.NET application, you need to use the DataAdapter object that ADO.NET provides. This object populates a disconnected DataSet object with the retrieved queries. You can then close the connection to the database.

Interoperability

VB.NET provides platform-independent access to data sources using the XML-based features of ADO.NET. In ADO.NET, the native form of the DataSet object is XML, which allows easy data exchange across heterogeneous systems. In addition, the text-based nature of XML allows data transfer over protocols, such as HTTP and HTTPS. As a result, XML-based data can easily traverse firewalls because firewalls block only binary information.

Say, for example, you have a VB 6.0 application that retrieves employee information from a database using the ADO recordset object. You need to deliver this information to a Java application, which utilizes the information for payroll purposes. You cannot transfer data across firewalls and heterogeneous systems without XML support. VB.NET uses the ADO.NET DataSet class to encapsulate the application data in the DataSet object. VB.NET application then passes the DataSet object to a Web service that allows the Java application to retrieve and use the passed data.

Backward Compatibility

VB.NET supports backward compatibility with existing Component Object Model (COM) components created using VB 6.0. You can incorporate these COM components in your .NET applications when you can neither migrate nor recode these COM components. For example, a COM component, TaskManager.dll, which you have created using VB 6.0, exposes methods to retrieve information about the tasks that an executive needs to perform. To implement this in VB.NET, instead of migrating the VB 6.0 application to VB.NET or recoding the VB 6.0 application in VB.NET, you can use the existing component.

Code in .NET applications is managed, while code in COM components is unmanaged. As a result, you need an interoperability mechanism that allows the managed and unmanaged code to interact. The two components that provide the required interoperability are:

  • COM Interop: Provides access to existing COM components and enables you to incorporate them in a .NET application. This is possible because COM Interop imports the COM types to the .NET application. COM interop also facilitates forward compatibility to allow you to call managed .NET code from COM clients.

  • Primary Interop Assembly (PIA): Contains a definition of the COM types that exist in the COM components you use in the .NET application. This information about COM types is included as metadata. The publisher of the COM type library provides the assembly that contains the metadata. PIA generates managed code when COM types convert to .NET types. For example, the DATE type in COM converts to the System.Date type in .NET.

In .NET clients, you can create a new instance of a COM type in the same way as you create an instance of a .NET type. For example, if the name of the class in TaskManager.dll is TaskManager, you can create an instance of this class in VB.NET using the following code:

 Dim objTaskManager as new TaskManager 
Note

To learn more about COM Interop, see Chapter5 of the book "Creating Components and Web Services in VB_NET".

Support for Creating Mobile Applications

You can create mobile applications using VB.NET; this was not possible in VB 6.0. Using mobile applications, you can access any type of data on mobile devices, such as cell phones or personal digital assistants, anytime and anywhere. Different mobile devices understand different programming languages. For example, cell phones understand Wireless Markup Language (WML) and pocket computers understand HTML. As a result, you need to create mobile applications specific to a mobile device. Using Microsoft Mobile Internet Toolkit (MMIT) or .NET Mobile, which the .NET Framework provides, you can create a mobile application without worrying about its device-specific implementation. The application generates output in a language that a mobile device understands. You can drag different Mobile controls to the form and create mobile applications.

An example of a mobile application is a service that displays the names and addresses of different restaurants in a given location. area. The list changes according to the current location of the mobile device.




Migrating Unmanaged Applications to. NET
Migrating Unmanaged Applications to. NET
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 31

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