Visual Basic .NET

Visual Basic. NET ( VB.NET abbr. ) is a programming language that is based on the Microsoft. NET Framework. It was published in 2002 and is not a simple evolution of its predecessor, Visual Basic 6, but has been redesigned in many areas.

Visual Basic. NET produces an intermediate code for a technology developed by Microsoft virtual machine, the Common Language Runtime ( CLR). This machine is included in the. NET Framework.

The intermediate code is not translated at runtime into machine code, through this intermediate stage of the virtual machine, it is interoperable with other. NET languages, the execution however, requires the. NET Framework.

Visual Basic. NET supports object-oriented programming completely and has exception handling, as it is also known from other programming languages ​​like Java or C .

  • 2.1 Windows Applications
  • 2.2 Web Applications
  • 2.3 Special features over others. NET languages
  • 2.4 Differences to Visual Basic Classic

History

Around the turn of the millennium Visual Basic had its initial advantage over other programming languages, simply create a graphical user interface forfeited. Many other high-level languages ​​now offered also the possibility to easily create Windows user interfaces, such as C using the Microsoft Foundation Classes ( MFC). In addition, Visual Basic had now developed into a complex and rather inhomogeneous product, the maintenance and improvement has become increasingly difficult. Probably for these reasons, Microsoft stopped the development of this product ( despite the commercial success and the protest of many VB programmers ) and the integrated Visual Basic programming language in the house. NET architecture. The language was changed to a high degree, in order to meet the demands of a. NET language. Thereby, the full object orientation, and the translation was made possible in the Common Intermediate Language.

2002-2003: Visual Basic NET.

With Visual Studio. NET was released in 2002 for the first time a version of Visual Studio, which built on the. NET Framework and therefore Visual Basic. NET supported. By propagating the at that time still quite young. NET technology and the name, " Visual Studio. NET" but the impression was created among the customers, if it were a product exclusively for this platform. This meant that many developers and companies reluctant to continue to use Visual Studio with the classic Visual Basic.

The first update to Visual Basic 7.1 and. NET Framework 1.1 (build 4322 ) and " Visual Studio. NET 2003 " brought only minor changes, which is reflected in the "small " version jump. Some may from Visual Basic 7.1, a counter variable in the head of a for loop are declared. In addition, the support for mobile devices was added. On these not. NET Framework 1.1 is used as a runtime environment, but the ". NET Compact Framework 1.0".

2005-2007: Visual Basic 8 and 9

In November 2005, the first major version jump. NET Framework and. NET Compact Framework to version 2.0, accompanied by the release of the new Visual Basic 8 as part of the "Visual Studio 2005 " (it will. " NET " is made the name omitted). With this version, some restructuring of the. NET runtime library were made. Most striking is the support of generic programming that is similar to the standard C templates. Many interfaces and attributes of the runtime library are also available as a generic implementation. Furthermore, a free, limited in scope Express Edition of Visual Basic. NET is available since version 2005.

With Visual Basic 8 IsNot operator was introduced which became a sensation when Microsoft had patented this invention. Another new feature is the My namespace, represents the various system-dependent functions in a clear way for the programmer, such as access to computer components, the Windows registry database or information about the operating system and the current user.

2007 in parallel with the release of Windows Vista, the new version of Visual Basic 9 and published " Visual Studio 2008 ". The largest linguistic change is probably the support of the new. NET component LINQ. Visual Basic 9 is based on the Windows Vista shipped and available for Windows XP. NET Framework 3.0 ( formerly WinFX ). Probably the most important part of the version update is the Windows Presentation Foundation, which will replace not only Windows Forms, but also the internal Windows GDI graphics subsystem.

Since November 2007, all Visual Studio 2008 versions are based on the NET Framework 3.5, with the following technologies have been introduced or expanded. Language Integrated Query (LINQ ), new compilers for C #, Visual Basic and C , ASP.NET with AJAX, ADO.NET Entity Framework data Provider support for SQL Server 2008, support for. NET Framework Client Profile, among others.

Properties

Windows applications

The Windows Forms technology is used for developing Windows applications. This is an event- oriented programming model, to be called at the appropriate event handlers, if the operating system a certain user action, such as pressing a button monitors.

Unlike Visual Basic 6 Windows Forms are not saved in a special format, but how to create normal classes and used by a corresponding base class (usually System.Windows.Forms.Form ) can be derived.

At instantiation of such a class in the constructor, the objects are created, to be displayed within the window. This model is used in the Java programming language.

Modern development environments allow visual creation of forms, the necessary for the constructor code generated by the development environment.

Web Applications

For the development of Web Applications ASP.NET is being used. In this case, a separation between the presentation of the website and the code to be executed, which is located in a VB.NET class. This has the advantage that the well-known ASP spaghetti code that just complicates the maintenance of larger projects, is avoided.

For the execution of ASP.NET applications, the Microsoft IIS or Apache HTTP server is required with the mod_mono module.

ASP.NET also enables the development of so-called web services. The information required for the publication of Web Services are generated by the development environment on the basis of attributes that fits the programmer in the program.

To access a web service can range from the development environment to request a class to be generated that encapsulate the access to the methods of the web service.

Unique features compared to others. NET languages

As a. NET language Visual Basic. NET is subject to the advantages and disadvantages of this platform. Visual Basic Classic made ​​many smaller things differently than other languages ​​. For backward compatibility, many of these points as " legacy" in Visual Basic. NET are included. A few examples:

  • Usually ( as in. NET Framework) corresponds to the converted into a number of logical value False or False to the value 0, True or True is interpreted as 1. In Visual Basic Classic True but stands for -1. This convention made ​​it possible not to have to distinguish between a logical and a binary Not operator (-1 = 11111111 in two's complement ). . Therefore in Visual Basic NET and there is still the conversions CInt ( True) or CType (True, Int32) -1; the call to the. NET Framework method Convert.ToInt32 (true ) evaluates to 1, however,
  • In most programming languages ​​declares a statement of the form int a; a five-member array with indices from 0 to 4 or 1 to 5 Declared In VB.NET Dim a (5 ) As Integer a sechselementiges array with indices from 0 to 5, to backward-compatible with VB syntax Classic Dim a ( [ lowerbound To] upper bound ) to stay.

Differences to Visual Basic Classic

To meet the demands of a. NET language, Visual Basic. NET over the previous Visual Basic versions was changed to a high degree. So the language is fully object -oriented. In addition, the source code will not be translated at compile into native Win32 code, but code in the Common Intermediate Language, the. NET equivalent of Java bytecode. This code is converted into machine code at runtime and can thus be adapted to the current platform.

The switch to. NET technology brought in addition to these changes in the background also changes to the programmer. The. NET Framework provides many function libraries are available, eg for file access or for reading and writing XML files. Most important here are the Windows Forms, which replaces the outdated Thunder - Forms system of prior versions for creating user interfaces. The most obvious difference between the Windows Forms against the Thunder Forms is the fact that no special file format used to store more, but the forms are created as classes through code. Here, the constructor of the window class is used to create the classes also represented by controls. Modern integrated development environments allow visual creation of forms, the necessary for the constructor of the window class code generated by the development environment. Furthermore, can be customized with Visual Basic. NET unlike previous versions create web applications by running in an ASP.NET environment the VB code. The GUI library used here is called Web Forms, and it is largely an adaptation of Windows Forms elements of the possibilities of Web browsers and other Web clients.

In addition to these advantages, the change involves, however, some problems. Since the language and function library have experienced such profound changes, a Visual Basic Classic Code project can be migrated only at great expense to the new version. Although Microsoft provides with its Visual Studio development environment with a so-called Migration Assistant. This converts the code structure usually correct order and dominated by a few special cases, the conversion of Thunder Forms to Windows Forms, but for example, has severe problems with graphics programming, because the graphics systems used by Visual Basic Classic (GDI, in Thunder - Forms Controls Encapsulated) and Visual Basic. NET (GDI ) are mutually incompatible in practice. For better portability, there is Microsoft next to the Migration Wizard to create a function in the collection. NET Framework ( in the Microsoft.VisualBasic namespace), which provides some important Visual Basic Classic features below. NET. Existing COM components can be used without restrictions. Besides the problem of incompatibility of the loss of the "Edit and Continue" feature in Visual Studio. NET was a major development technical step backwards, so you could 6 not change the code in debug mode and can continue to run without interruption, unlike Visual Basic. This feature, however, was introduced with Visual Basic 2005.

In Visual Basic. NET you can, unlike in Visual Basic Classic, and then create programs if you have not purchased a development environment. The. NET Framework has namely technical reasons, a command -line compiler called Vbc.exe.

Example

The following ( human-readable ) plain text ( or code ) represents a simple Visual Basic program, the " Hello World! " Outputs the message on the so-called standard output, which is usually a command window ( a console or even closer to called latin Console ) is:

Module Module1     Sub Main ()       Console.WriteLine ( "Hello World !")     end Sub   end Module Notes:

This program is a simple console application that consists of a single module. A module is treated under Visual Basic. NET as a class that can contain only static elements.

In this case, the module contains only the main statement, Main ' (or the Main procedure ), which is called usually when starting any application once first.

The output statement Console.WriteLine ' comes from. NET class library, and allows the output to the standard output, the output with a newline ( by adding, Line' is completed).

. Though the key word, receive modules ' for compatibility in Visual Basic NET remained, there is a more Compliant spelling for the Hello World program:

Class Hello World     Shared Sub Main ()       Console.WriteLine ( "Hello World !")     end Sub   end Class Two things to notice here. The keyword Module ' was, Class' replaced and before the definition of the main statement, Main ' is one, shared ' ( English for " shared "). The command, Shared ' gives the translator (also called compiler ) that the main statement can be used without instantiating the class. The keyword class ' tells the translator that it is a class.

Difference between ' class ' and ' modules ': In one class (Latin class ) are all members by default, private ' (literally " set apart" from the Latin for privatus, " isolated ", transferred or encapsulated ) and not shared '. These keywords must be preceded if necessary.

A module (' Module' ) is also a class, but here all the members are by default public ' ( from the Latin- English for " public" ) and, Shared ' - they can therefore be used without instantiation.

Development environments

For the development of VB.NET programs, it is sufficient if the. NET Framework is installed on the development computer. The program can be written using a simple text editor and then compiled with the included. NET command -line tool Vbc.exe.

For professional development, however, the use of the paid Visual Studio. NET is recommended. This is an IDE that allows creating Windows and Web applications.

For hobbyists a more limited but free version is labeled " Microsoft Visual Basic Express " available that is suitable especially for beginners. In addition, there are two free development environments. The SharpDevelop (short: # develop ), which also supports other NET languages ​​, as well as the derived MonoDevelop, the development environment of the Mono project, which is also available for non-Windows operating systems..

Legal Aspects

Visual Basic Classic, unlike many modern high-level languages ​​, not an open standard, but proprietary and intellectual property of Microsoft. With Visual Basic. NET, this binding is loose, as some parts of. NET infrastructure have been standardized by Ecma International. However, the patenting of the introduced in Visual Basic. NET 8 IsNot operator is again a step towards a closed environment.

799578
de