Visual Basic .NET from a Visual Basic 6.0 Perspective

Publish Date: Apr 16, 2014 | 28 Ratings | 3.57 out of 5 |  PDF

Overview

The .NET framework introduces sweeping changes in Microsoft software architecture, Visual Studio development tools, and networked systems development. If you have created an application based on components from Microsoft, or are planning to do so, you may need to learn more about .NET integration.

Table of Contents

  1. Introduction
  2. What Is .NET?
  3. Benefits of Visual Basic .NET
  4. What’s New? What’s Different?
  5. Property Pages
  6. Declaring Variables
  7. Error Capture
  8. .NET Designers
  9. Migrating, Porting, and Upgrading Your Visual Basic Code
  10. Conclusion

1. Introduction

The .NET framework introduces sweeping changes in Microsoft software architecture, Visual Studio development tools, and networked systems development. If you have created an application based on components from Microsoft, or are planning to do so, you may need to learn more about .NET integration.
At a high-level, the .NET framework aims to provide:

  • A consistent object-oriented programming environment
  • Simple software deployment and minimal versioning conflicts
  • A guarantee for safe execution of code
  • A consistent developer experience across a wide range of applications
  • Communication protocols on industry standards

While .NET does not necessarily introduce new functionality, it improves upon existing features and capabilities. Writing distributed applications, organizing large programs, interacting with multiple languages, and designing for maximum performance is now much easier in the .NET framework. If you have an application distributed over a network, an application containing a Web site front-end, a need for Web-based security, a desire for multilanguage interoperability, or a Visual Basic application that needs faster, better performance, then this article will help you apply .NET technology to your application development.
Note that realizing many of these new .NET features may be challenging for current Visual Basic programmers -- there are some complex code porting issues and syntactical differences when migrating from Visual Basic version 6.0 to Microsoft’s current version, Visual Basic .NET 2002. So, if you are not prepared to learn object oriented programming (OOP) or conform to new syntactical changes, you may want to access all of the .NET benefits from an open development environment like LabVIEW. With LabVIEW, you can take advantage of all of the .NET technology benefits from within the LabVIEW environment without having to learn Visual Studio .NET programming.


Back to Top

2. What Is .NET?

The .NET framework is a set of technologies for connecting your world of information, people, systems, and devices that contains five main components. The framework consists of the following five components that integrate together through the use of XML Web services.

  • Experiences: The end users’ convenient encounter with this connected world of services -- the ‘look and feel’ of the .NET framework
  • Clients: The set of software components that enable devices, such as PCs, PDAs, and cellular phones, to access information anywhere
  • Web Services are reusable applications written in XML that connect and integrate the other .NET components to provide secure and connected solutions
  • .NET Servers consist of the Windows 2000 family of servers that Microsoft recommends for hosting Web services -- these servers optimize the use of XML and include security implementations
  • Development Tools contain the application development environment (ADE) that you choose to use for developing your .NET application -- this is most commonly thought of as Visual Studio .NET, but can also be an open development environment such as LabVIEW

Take advantage of Visual Studio .NET resources including NI Example Code, Developer Insights Articles, Application Notes, and Tutorials.

Microsoft released Visual Basic .NET in conjunction with C# and C++ .NET within the Visual Studio .NET environment. Visual Basic .NET was by far the most affected by the new .NET technology and architecture. While you can realize .NET benefits with this new version of Visual Basic, the move to the new language may be challenging. Visual Basic .NET introduces many syntactical changes as well as migration issues for 6.0 users.

You may have begun your programming career with GW Basic or QuickBasic for DOS then moved to Visual Basic for Windows. Throughout the Basic language lifecycle, you could easily move working code from one version of Basic to the next with little or no changes and build on your Basic programming knowledge. Now, the upgrade path to Visual Basic .NET is not as simple. .Net has modified many coding rules, enforced certain programming practices, and exposed more low-level constructs for advanced developers.


Back to Top

3. Benefits of Visual Basic .NET

Many Visual Basic .NET benefits are a result of the overall .NET framework rather than the language. So, you can access many of these features from outside of Visual Studio .NET and from other open environments as well. However, some of the new features Visual Basic .NET offers include:

  • Seamless deployment
  • Memory leak monitoring
  • Robust debugging tools
  • Easy methods for reusing code
  • Integrated tools that generate Visual Basic .NET code for you


Back to Top

4. What’s New? What’s Different?

The integrated development environment (IDE) of Visual Studio has certainly changed with the advent of .NET technology, and Visual Basic reflects that transformation as well. Some of the major differences you will notice right away include:

  • Property pages replaced by property grid displays
  • Variant data type replaced by objects
  • Go Sub/Return replaced by structured exception handling
  • The addition of .NET designers

In addition to this short list, syntax changes exist with array manipulation, fixed-length strings, parameter byval/byref defaults, properties, assignments, resource files, static procedures, and file I/O manipulations, enumerations, and much more. This section provides an in-depth look at a few of the differences.


Back to Top

5. Property Pages

The ActiveX control property page design concept is no longer available in the .NET programming environment. Fortunately, while the configurations look different, you still have access to these options.



This image provides an example of how an ActiveX property page might appear in the Visual Basic 6.0 environment. In this graph's property pages, you can change the plot style, axis configurations, and other settings.

A measurement and control .NET graph integrates a window into the environment rather than linking each control differently.



This screen provides a view of the Visual Basic .NET property grid for the Measurement Studio .NET graph object. From the property grid, you can also launch collections editors, similar to the plot collection editor below. (Collections are a group of properties nested with the properties of the main control or object.)



So, while the ActiveX property pages are gone, the .NET controls have similar options to ensure flexibility and easy control configuration.


Back to Top

6. Declaring Variables

You will notice another major difference in the code during the development phase of the application. To declare variables as a Visual Basic 6.0 developer, you may type:

Dim num As Variant
Dim str As Variant

The ‘variant’ data type from Visual Basic 6.0 is not valid in any .NET language. Instead, you have to strong-type those variables if you want to declare them in Visual Basic .NET:

Dim num As Int16
Dim str As String


Back to Top

7. Error Capture

Similarly, the error catching methodologies have changed but still exist. A significant amount of development time was invested in improving the Visual Basic error handling process. Prior to Visual Basic .NET, developers widely used goto statements. Visual Basic now supports structured exception (error) handling, which allows the program to detect and possibly recover from errors during execution. Visual Basic .NET uses an enhanced version of the Try...Catch...Finally syntax already supported by other languages such as C++. Structured exception handling combines a modern control structure, similar to Select Case or While, with exceptions, protected blocks of code, and filters. Structured exception handling makes it easy to create and maintain programs with robust, comprehensive error handlers. Unstructured exception handling using On Error can degrade application performance and result in code that is difficult to debug and maintain.


Back to Top

8. .NET Designers

Finally, .NET Framework designers are completely new to the environment. A designer is an object that is responsible for managing the design time, behavior, and appearance of components on the design surface. The designers in Visual Studio .NET have a powerful and flexible built-in code generation. The code generation exposes straightforward extensibility to cover scenarios when the default handling does not meet your needs. The new NI Instrument I/O Assistant in Measurement Studio for Visual Studio .NET is a good example of a Visual Studio .NET designer. The designer is fully integrated into the Visual Studio environment rather than operating as a stand-alone application as it was with previous versions.




After interactively configuring your instrumentation setup, the integrated Instrument I/O Assistant then generates all of the code in proper Visual Basic .NET or Visual C# .NET syntax to reflect your changes within the designer.

Read more on new developments in Visual Basic


Back to Top

9. Migrating, Porting, and Upgrading Your Visual Basic Code

With all of these changes and improvements, Visual Basic did lose some backwards compatibility. To make the architecture change from ActiveX-based technology to the .NET Framework, Microsoft had to redesign Visual Basic from the ground up, which led to certain discontinuities. All of the differences listed in the previous section require manual updates from the developer. Microsoft has thoroughly outlined steps to preparing your Visual Basic code for an upgrade as well as practices to fix code that was not properly upgraded. The preparation includes practices such as using early-binding, avoiding null propagation, using zero bound arrays, safe typing all variant data types, and avoiding def<type> statements.
An upgrade wizard and detailed steps for preparing Visual Basic 6.0 code for conversion can help you ease this conversion. Learn more about the Visual Basic conversion wizard or about preparing your code for an upgrade.


Back to Top

10. Conclusion

In addition to application stability, Visual Basic .NET provides more power through an object-oriented language that solves many challenges Visual Basic developers face today. If you plan to use Visual Basic .NET for your upcoming projects, explore the Measurement Studio solutions to add measurement and control functionality to the general-purpose Visual Basic environment. However, if you have Visual Basic 6.0 projects to complete, Measurement Studio 6.0 offers ActiveX controls and C++ classes to abstract low-level I/O calls, deliver scientific user interface controls, provide advanced analysis capabilities, and connect live measurement data across any network easily. Finally, if you do not need to learn the .NET programming paradigm but you could benefit from leveraging the .NET framework, you should learn more about LabVIEW. LabVIEW has always leveraged the latest technologies and delivered them in a nondisruptive manner to the LabVIEW user without manually updating your code or learning a new programming paradigm each time a new technology is available. As a LabVIEW user, you will have access to the latest technologies while maintaining your development investments.
Related Links:
Join a Measurement Studio for .NET Languages Discussion Forum

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit