Visual Basic .NET

Visual Basic .NET in Microsoft Visual Studio 2003
Enlarge
Visual Basic .NET in Microsoft Visual Studio 2003

Visual Basic .NET (VB.NET) is an object-oriented computer language that can be viewed as an spiritual evolution of Microsoft's Visual Basic (VB) implemented on the Microsoft .NET framework. Its introduction has been controversial, as significant changes were made that broke backward compatibility with VB and caused a rift within the developer community that may or may not be resolved with the introduction of Visual Studio 2005.

The vast majority of VB.NET developers use Visual Studio .NET, although SharpDevelop provides an open-source alternative. The creation of open-source tools for VB.NET development have been slow compared to C#, although the Mono development platform provides an implementation of VB.NET-specific libraries and is working on a compiler, as well as the Windows Forms GUI library.

Contents

Versions of Visual Basic .NET

As of June 2005 there have been two versions of Visual Basic .NET, with a third close to release.

Visual Basic .NET

The original Visual Basic .NET was released alongside Visual C# and ASP.NET in 2002. C# — widely touted as Microsoft's answer to Java — received the lion's share of media attention, while VB.NET (being generally regarded as just VB7) was not widely covered. As a result, few outside the Visual Basic community paid much attention to it.

Those that did try the first version found a powerful but very different language under the hood, with significant disadvantages in some areas, including a runtime that was ten times as large to package as the VB6 runtime and a greatly increased memory footprint, although when compared to Java it fared rather better (http://www.javaworld.com/javaworld/jw-01-2003/jw-0110-j2eenet.html).

Visual Basic .NET 2003

Visual Basic .NET 2003 was released with version 1.1 of the .NET Framework. New features (http://msdn.microsoft.com/vstudio/productinfo/overview/whatsnew.aspx) included support for the .NET Compact Framework and a better VB upgrade wizard. Improvements were also made to the performance and reliability of the .NET IDE (particularly the background compiler (http://msdn.microsoft.com/msdnmag/issues/05/06/AdvancedBasics/default.aspx)) and runtime.

Visual Basic 2005

Visual Basic 2005 is the next iteration of Visual Basic .NET, Microsoft having decided to drop the .NET portion of the title.

For this release, Microsoft is adding many features (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vbnet2005_preview.asp) in an attempt to reintroduce some of the ease of use that Visual Basic is famous for — or infamous, with respect to "newbie" programmers — including:

  • Edit and Continue - probably the biggest "missing feature" from Visual Basic, allowing the modification of code and immediate resumption of execution
  • Design-time expression evaluation
  • The My pseudo-namespace (overview (http://msdn.microsoft.com/vbasic/default.aspx?pull=/msdnmag/issues/04/05/visualbasic2005/default.aspx), details (http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/vbmy.asp)), which provides:
    • easy access to certain areas of the .NET Framework that otherwise require significant code to access
    • dynamically-generated classes (notably My.Forms)
  • Improvements to the VB-to-VB.NET converter (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/VBUpgrade.asp)
  • The Using keyword, simplifying the use of objects that require the Dispose pattern to free resources
  • Just My Code, which hides boilerplate code written by the Visual Studio .NET IDE
  • Data Source binding, easing database client/server development

The above functions (particularly My) are intended to reinforce Visual Basic .NET's focus as a rapid application development platform and further differentiate it from C#.

Visual Basic 2005 will also introduce features meant to fill in the gaps between itself and other "more powerful" .NET languages, adding:

  • .NET 2.0 languages features (http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/LanguageEnhancements.asp) such as:
    • operator overloading [1] (http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/vboperatoroverloading.asp)
    • generics [2] (http://msdn.microsoft.com/vbasic/default.aspx?pull=/library/en-us/dnvs05/html/vb2005_generics.asp)
  • XML comments that can be processed by tools like NDoc to produce "automatic" documentation
  • Partial classes, a method of defining some parts of a class in one file and then adding more definitions later; particularly useful for integrating user code with auto-generated code
  • Support for unsigned integer data types commonly used in other languages

On the other hand, C# 2005 will have additional features that will not be in Visual Basic 2005:

  • Static classes
  • Refactoring, the ability to automatically re-organize code

IsNot Patent

One other feature, the conversion of

If Not X Is Y

to

If X IsNot Y

gained notoriety (http://www.theregister.co.uk/2005/02/22/real_slams_ms_patent/) when it was found to be the subject of a Microsoft patent application (http://appft1.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PG01&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.html&r=1&f=G&l=50&s1=%2220040230959%22.PGNR.&OS=DN/20040230959&RS=DN/20040230959).

Visual Basic 2005 Express

A new set of Visual Studio products called "Visual Studio 2005 Express Editions" are available in downloadable beta form. Microsoft states their intention to sell them for $49 in the Visual Studio 2005 FAQ (http://lab.msdn.microsoft.com/express/faq/). One of these products is Visual Basic 2005 Express.

The Express Editions are targetted specifically for people learning a language. They have a streamlined version of the user interface, and lack more advanced features of the standard versions. On the other hand, Visual Basic 2005 Express Edition does contain the Visual Basic 6.0 converter, so it is a reasonable way to evaluate feasibility of conversion from older versions of Visual Basic.

Relation to Visual Basic

Despite outward similarities — the name, for one — Visual Basic .NET is not Visual Basic. This is not obvious, as once you account for methods that have been moved around and which can be automatically converted, the basic syntax of the language has not seen many "breaking" changes, just additions to support new features like structured exception handling and short circuited expressions. One simple change that can be confusing to previous users is that of Integer and Long data types, which have each doubled in length; a 16-bit integer is known as a Short in VB.NET, while Integer and Long are 32 and 64 bits respectively. Similarly, the Windows Forms GUI editor is very similar in style and function to the Visual Basic form editor.

The things that have changed significantly are the semantics — from those of a procedural programming environment running on a deterministic, reference-counted engine based on COM to a fully object-oriented language backed by the .NET Framework, which consists of a combination of the Common Language Runtime (a virtual machine using generational garbage collection and a just-in-time compilation engine) and a far larger class library. The increased breadth of the latter is also a problem that VB developers have to deal with when coming to the language, although this is somewhat addressed by the My feature in Visual Studio 2005.

The changes have altered many underlying assumptions about the "right" thing to do with respect to performance and maintainability. Some functions and libraries no longer exist; others are available, but not as efficient as the "native" .NET alternatives. Even if they compile, most converted VB6 applications will require some level of refactoring to take full advantage (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchperfopt.asp) of the new language. Extensive documentation (http://msdn.microsoft.com/vbrun/staythepath/clientpath/default.aspx) is available to cover changes in the syntax, debugging applications, deployment and terminology.

Comparative samples

Template:Section-stub

The following simple example demonstrates similarity in syntax between VB and VB.NET:

Classic VB example:

 Private Sub Command1_Click()
  
    MsgBox "Hello, World"
  
 End Sub

A VB.NET example:

 Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
  
       MsgBox("Hello, World")
  
 End Sub
  • Note that all procedure calls must be made with parenthesis in VB.NET, whereas only function calls would be in Visual Basic.

Controversy concerning VB.NET

Many long-time Visual Basic programmers have complained loudly (http://www.mvps.org/vb/index2.html?rants/vfred.htm) about Visual Basic .NET, because initial versions dropped a large number of language constructs and user interface features (http://vb.mvps.org/vfred/breaks.asp) that were available in VB6 (which is now no longer sold), and changed the semantics of those that remained; for example, in VB.NET parameters are (by default) passed by value, not by reference. Detractors refer to VB.NET as Visual Fred (what they think it should have been called, to distinguish it from VB6) or DOTNOT. On March 8, 2005, a petition (http://classicvb.org/petition/) was set up in response to Microsoft's refusal to extend its mainstream support (http://msdn.microsoft.com/vbasic/support/vb6.aspx) for VB6 at the end of that month.

VB.NET's supporters state that the new language is in most respects more powerful than the original, incorporating modern object oriented programming paradigms in a more natural, coherent and complete manner than was possible with earlier versions. Opponents tend not to disagree with this, instead taking the position that although VB6 has flaws in its object model, the cost in terms of redevelopment effort is too high for any benefits that might be gained by converting to VB.NET. Independent developers producing software for Internet distribution have also taken issue with the size of the runtime.

Microsoft supplies an automated VB6-to-VB.NET converter with Visual Studio .NET, which has improved over time, but it cannot convert all code, and almost all non-trivial programs will need some manual effort to compile. Most will need a significant level of refactoring to work optimally. Visual Basic programs that are mainly algorithmic in nature can be migrated with few difficulties; those that rely heavily on such features as database support, graphics, unmanaged operations or on implementation details are more troublesome. Unfortunately, these functions are core to many business applications.

Microsoft's response to developer dissatisfaction has focussed around making it easier to move new development and shift existing codebases from VB6 to VB.NET. Their latest offering is the VBRun website (http://msdn.microsoft.com/VBRun/), which offers code samples and articles for:

  • completing common tasks in VB6, like creating a print preview
  • integrating VB6 and VB.NET solutions (dubbed VB Fusion)
  • converting VB6 code to VB.NET

See also

Template:Wikibookspar

External links


Template:Major programming languages smallde:Visual Basic .Net es:Visual Basic.NET ja:Microsoft Visual Basic .Net it:VB.NET no:Vb.net ru:Visual Basic .NET zh:VB.NET

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools