Software Development

What's new in VB.NET?

If you're a VB programmer, chances are you're anticipating the enhancements promised by Microsoft .NET. This article kicks off a series that focuses on VB.NET from the VB programmer perspective. Here's a look at some of the big language and IDE changes.

By Irina Medvinskaya

Visual Basic has long been a favorite tool of many developers. Its relative ease of use appeals to technology pros and novice programmers alike. VB has been used to develop client-server applications, and with the introduction of Version 6, developers were able to develop some Web components. However, true Web development has remained out of reach. All of this is about to change with the release of .NET technology planned by Microsoft for the last quarter of 2001. You may have heard the rumors of this great initiative that is about to change what we develop and how we develop it. Here are some highlights of what’s on the VB.NET horizon.

Summary of major language and IDE changes
Keep in mind that Microsoft has made only a first beta version available; future releases may bring additional changes. But even though the full version release is still months ahead, it pays to know what to expect.

Language
Variant data type is no longer used. Instead, Object becomes a data type that can contain any kind of data.

Integer and Long: Integer variables are stored as 32-bit numbers, and Long variables are stored as 64-bit numbers. VB6's Integer data types have been replaced with Short data types stored as 16-bit numbers.

Date variables are stored as 64-bit integers, so you can’t manipulate them directly as Double. ToOADate and FromOADate functions have been added to provide conversion between Date and Double values.

Fixed-length strings are no longer supported.

Type has been replaced with Structure.

True has a value of 1 instead of -1, as in VB6.

Empty/Nothing: Object variables are no longer initialized to Empty but to Nothing. Empty converts to zero when used in a numeric expression and to an empty string when used in a string expression.

Local variables inside blocks are supported in VB.NET. A local variable declared inside a loop, for example, will have a scope only inside that loop and not inside the function or procedure where it is declared.

Arrays: All arrays are 0 based, making the Option Base statement unnecessary. All arrays are dynamic. You can use the Dim statement both to declare and initialize the array. The Redim statement is used only for allocating or reallocating the space for an array, rather than for reallocating the array.

Calling procedures: When calling procedures, parentheses are required around the argument lists regardless of whether a procedure is called with or without a Call statement.

Static procedures: The static keyword isn’t supported on the procedure; all static local variables must be explicitly declared with the Static statement.

ByVal/ByRef: The default for passing parameters is ByVal.

ParamArray parameters: Variables that are passed to a ParamArray can't be modified by the called function. As in Version 6, ByRef ParamArray elements are not supported.

Default properties are not supported in VB.NET. You must explicitly specify the property name for each control/object.

While loops: A WEnd statement is no longer used to terminate While loops. Instead, End While is used.

On…GoTo/On…GoSub are no longer supported, but On Error GoTo is.

Debug.Print has been replaced byDebug.WriteLine and Debug.Write. Debug.WriteLine writes a line of text to the Output window. Debug.Write outputs the text to the Output window without a linefeed.

Resource files: While Version 6 allows having only one resource file per project, VB.NET allows multiple resource files.

IDE
The new IDE is shared by all project types under Visual Studio.NET. This major improvement will make it easier to create add-ins that work with different types of projects.
  • VS.NET Home Page is the first window you’ll see when you start Visual Studio.NET. It shows the projects you recently worked on and includes options to open an existing project that is not on the list or to create a new project. The New Project dialog box provides options for creating a project in any VS.NET language.
  • The VB6 Project Explorer has been replaced by a Solution Explorer in VB.NET (see Figure A). It shows references in addition to modules.

Figure A
VB.NET’s Solution Explorer

  • A toolbox is hidden by default. It shows all controls available with an icon and a name for each (see Figure B).

  • Figure B
    The VB.NET toolbox

  • The new Task List lets you create a To Do list; code generators and the upgrade tool will post items in the Task List automatically (see Figure C).

  • Figure C
    VB.NET’s Task List

    • The Form Layout Toolbar offers more options for the control appearance on the form.
    • The code editor allows hiding/showing some parts of the code by clicking on the "+" and "-" signs.

    Windows applications
    Forms: VB forms have been replaced by Windows Forms (WinForms) that were built anew to take the full advantage of the .NET technology. WinForms take advantage of the deployment, application isolation, versioning, and code-access security features, making windows client applications easier to deploy and update. You can use WinForms in the browser, and they offer a number of new features, including automatic form resizing, control docking, visual inheritance, and an in-place menu editor.

    PrintForm method is no longer available. VB.NET offers a new printing framework that allows building print documents and offers a Print Preview dialog box.

    Caption property has become the Text property for all VB controls for consistency.

    Fonts: In VB6, you can use any Windows font. In VB.NET, you can use only TrueType or OpenType fonts. If your application currently uses other fonts, they will be automatically upgraded to the default Windows Form font, but all of the formatting, such as size, bold, and italics, will be lost.

    Interval property of Timer control: In VB6, the Interval property sets or returns the number of milliseconds between calls to the Timer events; setting it to 0 disables the control even when the control is enabled. In VB.NET, you disable the control by setting the Enabled property to False. The Interval property can't be set to 0.

    OLE Container control is unavailable in VB.NET. To use an equivalent of OLE Container control, you’ll need to add a WebBrowser control to the form and use it as an OLE Container control.

    Image control is unavailable in VB.NET. Instead, the PictureBox control has replaced both VB6's Image and PictureBox controls and offers some additional features, such as support for animated GIFs.

    Shape and Line controls have been replaced by System.Drawing. To draw shapes on forms, you can override the OnPaint event and paint shapes and lines by using Draw methods.

    Clipboard in VB.NET is different from VB6. It provides more functionality and supports more formats than in VB6. VB6 code that uses Clipboard operations can't be updated automatically and will show an upgrade error because of changes to the object model.

    DDE is not supported in VB.NET.

    Web applications
    ActiveX documents and DHTML applications can't be upgraded to VB.NET. To achieve the same functionality, you can use Web Forms and Windows Forms controls hosted in a browser.

    WebClasses have been upgraded to Web Forms, which you use to create a browser-based user interface for Web applications. VB.NET has a WYSIWYG designer for graphical creation of Web Forms using the Toolbox, allowing Web applications to have the same look as Windows applications. One of the advantages of Web Forms is that you don’t have to stop and restart IIS server to deploy new bits, as you do with WebClasses.

    Data
    VB.NET supports ADO, RDO, and DAO. ADO's new version, ADO.NET, provides additional classes for disconnected data access, offering performance and scalability improvements over the previous version. ADO.NET also allows simpler integration of XML data. DAO and RDO data binding is not available in VB.NET. ADO data binding has been upgraded to ADO.NET.

    Installing VB.NET
    To install VB.NET, you must first obtain Visual Studio.NET. If you’re an MSDN Universal Subscriber, you can download Visual Studio.NET. Nonsubscribers can sign up for MSDN or order Visual Studio.NET Beta 1 on CD.

    System requirements
    According to Microsoft, Beta 1 has been tested on Windows 2000, Windows NT 4.0, Windows Millennium edition, and Windows 98. Web application development and some server-side components may require Windows NT or Windows 2000. Table A shows Microsoft’s recommended configuration.

    Table A
    Beta 1 minimum requirements Beta 1 recommended requirements
    Pentium II 450-MHz or compatible processor Pentium III 733-MHz or compatible processor
    128 MB of RAM 256 MB of RAM
    Video card capable of 800x600 screen resolution, 256 colors Video card configured to 1024x768 screen resolution, High Color
    1-GB hard disk available space 1-GB hard disk available space
    CD-ROM drive CD-ROM drive
    System requirements

    One important note: You should not install Visual Studio.NET on a production machine, even if it’s your own computer at home. Dedicate a separate machine at work to play with VB.NET and partition your home computer to install VB.NET; otherwise, you risk crashing your computer. Also, keep in mind that the beta software is not uninstallable; so in order to remove it you may have to reformat the hard drive.

    What’s next?
    This concludes our first look at some of the things you’ll find as you start working with VB.NET. Next time, we’ll look at some of the language modifications that you will need to make as you upgrade to VB.NET.

    Irina Medvinskaya is a programmer/analyst at Citigroup for the Treasury Systems department in New York.

    0 comments