Tuesday, May 31, 2011

VB.NET

Visual Basic .NET (VB.NET) is an object-oriented computer programming language that can be viewed as an evolution of the classic Visual Basic (VB) which is implemented on the .NET Framework. Microsoft currently supplies two major implementations of Visual Basic: Microsoft Visual Studio, which is commercial software and Microsoft Visual Studio Express, which is free of charge.
Contents
[hide]



[edit] System and Hardware Requirements

* System
o Windows XP Service Pack 2 or above (for 2010 release, Service Pack 3)
o Windows Server 2003 Service Pack 1 or above
o Windows Server 2003 R2 or above
o Windows Vista
o Windows Server 2008
o Windows 7
* Hardware
o Minimum: 1.6 GHz CPU, 384 MB RAM, 1024×768 display, 5400 RPM hard disk
o Recommended: 2.2 GHz or higher CPU, 1024 MB or more RAM, 1280×1024 display, 7200 RPM or higher hard disk

[edit] Versions

There are four versions and five releases of Visual Basic .NET implemented by the Visual Basic Team.
[edit] Visual Basic .NET 2003 (VB 7.1)

Visual Basic .NET 2003 was released with version 1.1 of the .NET Framework. New features 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) and runtime. In addition, Visual Basic .NET 2003 was available in the Visual Studio.NET Academic Edition (VS03AE). VS03AE is distributed to a certain number of scholars from each country without cost.
[edit] Visual Basic 2005 (VB 8.0)

Visual Basic 2005 is the name used to refer to the Visual Basic .NET, Microsoft having decided to drop the .NET portion of the title.

For this release, Microsoft added many features, including:

* Edit and Continue
* Design-time expression evaluation.
* The My pseudo-namespace (overview, details), which provides:
o easy access to certain areas of the .NET Framework that otherwise require significant code to access
o dynamically-generated classes (notably My.Forms)
* Improvements to the VB-to-VB.NET converter[2]
* The Using keyword, simplifying the use of objects that require the Dispose pattern to free resources
* Just My Code, which when debugging hides (steps over) boilerplate code written by the Visual Studio .NET IDE and system library code
* 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 introduced features meant to fill in the gaps between itself and other "more powerful" .NET languages, adding:

* .NET 2.0 languages features such as:
o generics[3]
o 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
o Nullable Types[4]
* Support for unsigned integer data types commonly used in other languages

[edit] 'IsNot' operator patented

One other feature of Visual Basic 2005 is the IsNot operator that makes 'If X IsNot Y' equivalent to 'If Not X Is Y', which gained notoriety[5] when it was found to be the subject of a Microsoft patent application.[6][7]
[edit] Visual Basic 2008 (VB 9.0)

Visual Basic 9.0 was released together with the Microsoft .NET Framework 3.5 on 19 November 2007.

For this release, Microsoft added many features, including:

* A true conditional operator, "IIf(condition as boolean, truepart, falsepart)", to replace the "IIf" function.
* Anonymous types
* Support for LINQ
* Lambda expressions
* XML Literals
* Type Inference
* Extension methods

[edit] Visual Basic 2010 (VB 10.0)

In April 2010, Microsoft released Visual Basic 2010. Microsoft had planned to use the Dynamic Language Runtime (DLR) for that release[8] but shifted to a co-evolution strategy between Visual Basic and sister language C# to bring both languages into closer parity with one another. Visual Basic's innate ability to interact dynamically with CLR and COM objects has been enhanced to work with dynamic languages built on the DLR such as IronPython and IronRuby.[9] The Visual Basic compiler was improved to infer line continuation in a set of common contexts, in many cases removing the need for the "_" line continuation character. Also, existing support of inline Functions was complemented with support for inline Subs as well as multi-line versions of both Sub and Function lambdas.[10]
[edit] Relation to older versions of Visual Basic (VB6 and previous)

Whether Visual Basic .NET should be considered as just another version of Visual Basic or a completely different language is a topic of debate. This is not obvious, as once the methods that have been moved around and that can be automatically converted are accounted for, 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. Two important data type changes occurred with the move to VB.NET. Compared to VB6, the Integer data type has been doubled in length from 16 bits to 32 bits, and the Long data type has been doubled in length from 32 bits to 64 bits. This is true for all versions of VB.NET. A 16-bit integer in all versions of VB.NET is now known as a Short. Similarly, the Windows Forms GUI editor is very similar in style and function to the Visual Basic form editor.

The version numbers used for the new Visual Basic (7, 7.1, 8, 9, ...) clearly imply that it is viewed by Microsoft as still essentially the same product as the old Visual Basic.

The things that have changed significantly are the semantics—from those of an object-based programming language 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 of the new language. Documentation is available to cover changes in the syntax, debugging applications, deployment and terminology.[11]
[edit] Comparative samples

The following simple example demonstrates similarity in syntax between VB and VB.NET. Both examples pop up a message box saying "Hello, World" with an OK button.

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

A VB.NET example, MsgBox or the MessageBox class can be used:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Msgbox("Hello, World")
End Sub
End Class

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("Hello, World")
End Sub
End Class

* Both Visual Basic 6 and Visual Basic .NET will automatically generate the Sub and End Sub statements when the corresponding button is clicked in design view. Visual Basic .NET will also generate the necessary Class and End Class statements. The developer need only add the statement to display the "Hello, World" message box.
* Note that all procedure calls must be made with parentheses in VB.NET, whereas in VB6 there were different conventions for functions (parentheses required) and subs (no parentheses allowed, unless called using the keyword Call).
* Also note that the names Command1 and Button1 are not obligatory. However, these are default names for a command button in VB6 and VB.NET respectively.
* In VB.NET, the Handles keyword is used to make the sub Button1_Click a handler for the Click event of the object Button1. In VB6, event handler subs must have a specific name consisting of the object's name ("Command1"), an underscore ("_"), and the event's name ("Click", hence "Command1_Click").
* There is a function called MsgBox in the Microsoft.VisualBasic namespace which can be used similarly to the corresponding function in VB6. There is a controversy about which function to use as a best practice (not only restricted to showing message boxes but also regarding other features of the Microsoft.VisualBasic namespace). Some programmers prefer to do things "the .NET way", since the Framework classes have more features and are less language-specific. Others argue that using language-specific features makes code more readable (for example, using int (C#) or Integer (VB.NET) instead of System.Int32).
* In VB 2008, the inclusion of ByVal sender as Object, ByVal e as EventArgs has become optional.

The following example demonstrates a difference between VB6 and VB.NET. Both examples close the active window.

Classic VB Example:

Sub cmdClose_Click()
Unload Me
End Sub

A VB.NET example:

Sub btnClose_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnClose.Click
Me.Close()
End Sub

Note the 'cmd' prefix being replaced with the 'btn' prefix, conforming to the new convention previously mentioned.

Visual Basic 6 did not provide common operator shortcuts. The following are equivalent:

VB6 Example:

Sub Timer1_Timer()
Me.Height = Me.Height - 1
End Sub

VB.NET example:

Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Me.Height -= 1
End Sub

1 comment: