Visual Basic

Visual Basic .NET Meanings

What is Visual Basic .NET?

Visual Basic .NET is an object-oriented programming language that is made available by Microsoft in connection with the .NET Framework. With the aid of the Visual Studio development environment, which is currently available in version 2017, you can program in several languages, including in Visual Basic .NET.

The origins of Visual Basic .NET lie in the BASIC programming language, which first appeared in 1964. The programming language Visual Basic is introduced by Microsoft in 1991 together with an integrated development environment. Among other things, it enables the simple creation of applications with user interfaces. In 2002 Microsoft introduced the completely newly developed, object-oriented programming language Visual Basic .NET.

The .NET Framework provides class libraries, programming interfaces, and utilities for developing applications. In addition, a runtime environment is made available for executing the applications.

You can use the freely available community version of the Visual Studio 2017 development environment. It can be downloaded from Microsoft at and installed on your Windows PC. The development environment includes an editor for creating the program code, a compiler for creating the executable programs, a debugger for troubleshooting and much more.

What do I do with Visual Basic .NET?

With Visual Basic .NET and Visual Studio, different types of applications can be created, including:

  • Classic Windows Forms applications with easy-to-create graphical user interfaces and event-oriented programming.
  • Modern WPF applications with XAML. The Windows Presentation Foundation (WPF) class library, which was introduced in 2006, and the eXtensible Application Markup Language (XAML) are used.
  • Database applications with read and write access to many different database systems. To access relational databases, you can work with the ADO.NET framework as part of the .NET framework.
  • Dynamic internet applications in which the web pages serve as interactive user interfaces. The ASP.NET framework is used as part of the .NET framework. ASP stands for Active Server Pages.

An example program

This section is an example of a database application using Visual Basic .NET. If you have no programming experience yet, this example is intended to illustrate a typical use: Reading and outputting information from a database using the ADO.NET framework, see Figure 1. If you already have knowledge of another programming language, see the Code and the short comments, many well-known elements, but also many elements that are specific to Visual Basic .NET. Of course, this demo example is not yet suitable for a thorough learning of Visual Basic .NET. At this point I refer to my book at Rheinwerk-Verlag .

Structure of the database

A Microsoft Access database is accessed with a single table. You can see the structure of the table in Figure 2, the sample data in Figure 3.

The code of the program

This is followed by that part of the (extensive) program code that leads to the output of the data as shown in Figure 1:
‘ Import zusätzlicher Klassenbibliotheken
Imports System.Data.OleDb

‘ Klasse zur Darstellung und Benutzung des Formulars
Class Form1
‘ Erstellung der Objekte für den Zugriff
Private con As New OleDbConnection
Private cmd As New OleDbCommand
Private reader As OleDbDataReader

‘ Ereignis: Formular wird geladen
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
‘ Verbindung zur Datenbank definieren
con.ConnectionString =
“Provider=Microsoft.ACE.OLEDB.12.0;” &
“Data Source=C:\Temp\firma.accdb”
cmd.Connection = con
End Sub

‘ Ereignis: Benutzer betätigt Schaltfläche
Private Sub CmdAlleSehen_Click(sender As Object, e As EventArgs) _
Handles CmdAlleSehen.Click
‘ Mehrfach genutzte Prozedur aufrufen
End Sub

‘ Mehrfach genutzte Prozedur
Private Sub AlleSehen()
‘ Ausnahmebehandlung bei Zugriffsproblem
‘ Verbindung öffnen
‘ SQL-Befehl zum Abruf aller Daten erstellen
cmd.CommandText = “SELECT * FROM personen”
‘ Aufruf einer Prozedur zur Ausgabe
Catch ex As Exception
End Try
‘ Verbindung schließen
End Sub

‘ Mehrfach genutzte Prozedur
Private Sub Ausgabe()
‘ SQL-Befehl senden, Ergebnis speichern
reader = cmd.ExecuteReader()
‘ Listenfeld vor Ausgabe leeren
‘ Schleife zum Lesen und Ausgeben des gesamten Ergebnisses
Do While reader.Read()
LstAnzeige.Items.Add(reader(“name”) & ” # ” & reader(“vor” &
“name”) & ” # ” & reader(“personalnummer”) & ” # ” &
reader(“gehalt”) & ” # ” & reader(“geburtstag”))
‘ Zugriff auf Ergebnis beenden
End Sub
End Class

Visual Basic