Home > Articles

Writing Professional Visual Basic Applications

In this chapter, you'll get a quick look at what Visual Basic.NET is, and what's new in this version. You'll also get an idea of the work involved in upgrading older applications from VB6 to VB.NET, and a brief introduction to the .NET Framework.
This pre-publication chapter is from Sams Teach Yourself More VB.NET in 21 Days, by Lowell Mauer (0672322714). Content is based on a pre-Beta 2 build of Microsoft's .NET technology.

Welcome to the next generation of Visual Basic. In every new release of Visual Basic, Microsoft has added many new features, enhanced some others, and removed or replaced some older capabilities. With the release of Visual Basic.NET, Microsoft has done it again. In fact, Visual Basic.NET brings together new technologies that will make your applications more efficient, easier to deploy, and Web-enabled.

Today, you get a quick look at what Visual Basic.NET is, and what's new in this version. Along the way, you will get an idea of the work involved in upgrading older applications from VB6 to VB.NET. One of the biggest changes that Microsoft has made is the inception of the .NET Framework. We will introduce this new environment today and cover it in a little more detail on Day 4, "Understanding the .NET Framework." You also will look at what it takes to transition from Visual Basic 6 to the new .NET environment.

You will also see what drives the type of application you're creating. This involves choosing an application that makes sense and creating a life cycle or project plan for the application that takes it from an idea to the final product.

Also, you'll start a new demo project in Visual Basic. Although you probably know how to do this already, it's a good idea to review it. You do this not just for the steps needed, but to discuss the options available to you with the project properties, focusing on what they can do for you during the development and testing process. Naming conventions will also be covered; however, you won't be shown lists of what they should be. Instead, you'll learn why you need them and how they should be used.

Finally, at the end of today's lesson, some of the more advanced controls and features included in Visual Basic will be covered. You'll see what they are, how to use them individually and together, and—more importantly—why you should use them.

A Brief Look at What's New in Visual Basic.NET

Visual Basic.NET is the next version of Visual Basic. Rather than simply add some new features to Visual Basic 6.0, Microsoft reengineered the product to make it easier than ever before to write distributed applications such as Web and enterprise systems. Visual Basic.NET has two new packages for creating forms (Windows Forms and Web Forms); a new version of ADO for accessing disconnected data sources; and has streamlined the language, removing older, unused keywords, among other changes.

These new features will allow you to create both client/server applications and Internet-based applications. With Web Forms and ADO.NET, you can now rapidly develop scalable Web sites. With the addition of inheritance, the language is now an object-oriented programming environment. Windows Forms natively supports accessibility and visual inheritance. Finally, deploying your applications is now as simple as copying your executables and components from directory to directory.

Also, Visual Basic.NET is now fully integrated with the other Microsoft Visual Studio.NET languages. Not only can you develop application components in different programming languages, but also your classes can now inherit from classes written in other languages using cross-language inheritance. With the unified debugger, you can now debug multiple language applications, whether they are running locally or on remote computers. Finally, whatever language you use, the Microsoft .NET Framework provides a rich set of APIs for use in Windows and the Internet.

Changes to the Visual Basic Language

Whereas earlier versions of Visual Basic had been directed toward standard client applications, Visual Basic.NET is intended for creating Web service applications as well as the standard Windows client applications. This is done by generating managed code for the .NET framework and Common Runtime (discussed later in this section). This, of course, required significant changes to the Visual Basic language.

Although Visual Basic has retained many of its original features, modified and enhanced others, and added new features, it's inevitable that this led to some inconsistency and redundancy within the language. With the major changes required for the .NET Framework and runtime, Microsoft decided that it was a good opportunity to clean up many of the outdated aspects of the Visual Basic language.

The changes that were made are intended to do the following:

  • Simplify the language and make it more consistent

  • Add new features that have been requested

  • Make the code easier to read and maintain

  • Enhance the error processing

  • Make applications easier to debug

The New Windows Forms

Windows Forms is part of the new.NET Framework and leverages many new technologies including a common application framework, managed execution environment, integrated security, and object-oriented design principles. Windows Forms also offers full support for quickly and easily connecting to XML Web services and building rich, data-aware applications based on the ADO.NET data model. With the new shared development environment in Visual Studio, developers can create Windows Forms applications with any languages supporting the .NET platform.

Creating a Windows Forms application is done much the same way as it was done in previous releases of Visual Basic. Controls are placed on the form and then positioned as required. To edit the source code, simply double-click a control to open the source editor.

Visual Inheritance

Visual inheritance is one key new feature available in Windows Forms that will enhance developer productivity and facilitate code reuse. For example, you could define a standard main form that contains items such as a standard main menu and perhaps a common toolbar. This form can be used in other applications through inheritance and extended to meet the requirements of specific applications while promoting a common user interface and reducing the need to re-create the same forms. The creator of this base form or template can specify which elements can be extended and which must be used as-is, ensuring that the form is reused appropriately.

Precision Form Design

With the new Windows Forms, you now have an unprecedented level of control and productivity when designing the look and feel of your applications. Features such as the Menu Designer, Anchoring, Docking, and many other new controls enable a higher level of power and precision for developers building rich Windows-based user interfaces.

Windows Forms provides you with a rich set of technologies for building Windows-based applications. Not only are there new controls and features for fine-tuning the user interface, but Windows Forms also provides flexible deployment and integrated security.

The New Web Forms

Web Forms was created to address the differences between the techniques in use to build a Windows application and those used to create a Web application. With Visual Basic.NET you can now rapidly develop applications that will run on the Internet using the exact same techniques that you have already learned in Visual Basic.

To create a Web application, simply add a Web Form to your project, drag the controls you need onto the page, and then double-click each control to add the code required. Web Forms provides the following advantages:

  • Separates the HTML layout from the code behind the page. This separation makes it easier to update either piece independently of the other, simplifying code navigation and enabling code to be versioned more easily

  • Greatly enhances runtime performance because the code behind the HTML page is compiled into an executable, not script

  • Generates HTML pages in HTML 3.2, which means the page can be viewed on any platform, with any browser. Alternatively, you can target the special capabilities of a specific browser or wireless device

Previous versions of Visual Studio tools have attempted to simplify Web development. For example, Visual Basic provided support for DHTML clients and WebClasses while Visual InterDev assisted in the development of Active Server Pages (ASP). Web Forms address these issues and are the fundamental way to build Web applications with Visual Basic.NET. Web Forms represent an evolution of ASP and WebClasses providing the best of both models.

Transitioning from Visual Basic 6

Microsoft considered two options when designing Visual Basic.NET: retrofit the existing code base to run on top of the .NET Framework, or build from the ground up, taking full advantage of the platform. To deliver the features most requested by customers (for example, inheritance and threading) and ensure that Visual Basic moves forward into the next generation of Web applications, the decision was made to build Visual Basic.NET from the ground up on the new .NET Framework.

Visual Basic.NET enables a fundamental shift from traditional Windows development to building next-generation Web and Windows applications. For this reason, your code will need to be upgraded to take advantage of Visual Basic.NET. Thankfully, Microsoft has provided an Upgrade Wizard to help you perform this task. When you open a Visual Basic 6 project in Visual Basic.NET, the Upgrade Wizard will automatically start to step you through the upgrade process and will create a new Visual Basic.NET project, leaving your existing project untouched.

When your project is upgraded, the language is modified for any syntax changes and your Visual Basic 6.0 Forms are converted to Windows Forms. In most cases, you will have to make some changes to your code after it's upgraded. This is required because certain objects and language features either have no equivalent in Visual Basic.NET, or have an equivalent too different for an automatic upgrade. After the upgrade, you may also want to modify your application to take advantage of some newer features in Visual Basic.NET.

When you use the Upgrade Wizard, most required language and object changes will be made for you. The Upgrade Wizard is started when you open a Visual Basic 6 application. It will ask you about the project type and set options for your application (see Figure 1.1). At this moment, leave the defaults displayed.

Figure 1.1 Upgrading your Visual Basic 6 application using the wizard.

The next step is to specify where you want the new .NET project to be saved. Remember that your original project won't be modified. Once completed, the new project will remain open in the Solutions Explorer. You can then display the Upgrade report to see what issues you need to resolve as shown in Figure 1.2.

Figure 1.2 Working with the Upgrade report to resolve Visual Basic language issues.

Two very good documents are available from the Microsoft Visual Basic.NET Web site:

  • Preparing Your VB 6 Applications for the Upgrade to VB.NET

  • The Transition from Visual Basic 6.0 to Visual Basic.NET

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020