Visual Basic

This article is about the Visual Basic language shipping with Microsoft Visual Studio 7.0 and earlier. For the Visual Basic shipping with Microsoft Visual Studio .NET, see Visual Basic .NET.

Visual Basic (VB) is an event driven programming language and associated development environment created by Microsoft. It is derived heavily from BASIC. VB enables Rapid Application Development (RAD) of graphical user interface (GUI) applications, easy access to databases using DAO, RDO, or ADO, and easy creation of ActiveX controls. A programmer can quickly put together an application using the components provided with Visual Basic itself.

Contents

Derivative languages

Microsoft has developed a number of Visual Basic versions for scripting applications:

  • VBScript is the default language for Active Server Pages and can be used in Windows scripting and client-side web page scripting. Although it resembles VB in syntax, it is a separate language and it is executed by the Windows Scripting Host as opposed to the VB runtime. These differences can affect the performance of an ASP web site (namely inefficient string concatenation and absence of short-cut evaluation).

When wishing to create a new programming tool, Microsoft had the option to either modify the popular Visual Basic 6.0, or create a totally new tool from the ground up. They chose the latter, and developed Visual Basic .NET, the successor to Visual Basic 6.0, which is part of Microsoft's .NET platform. The VB.NET programming language is surprisingly very different to that of VB6, however, the application itself does feature the ability to import and convert existing VB6 project files.

Language features

A typical session in Microsoft Visual Basic 6
Enlarge
A typical session in Microsoft Visual Basic 6

Visual Basic was designed to be usable by all programmers, whether novice or expert. Forms are created using drag and drop techniques. A tools palette is used to place controls (e.g., text boxes, buttons, etc.) on the form (window). Controls have attributes and event handlers associated with them. Default values are provided when the control is created, but may be changed by the programmer. Many attribute values can be modified during run time based on user actions or changes in the environment, providing a dynamic application. For example, code can be inserted into the form resize event handler to reposition a control so that it remains centered on the form, expands to fill up the form, etc. By inserting code into the event handler for a keypress in a text box, the program can automatically translate the case of the text being entered, or even prevent certain characters from being inserted.

A Visual Basic application can consist of one or more windows, or a single window that contains child windows, as provided by the operating system. Dialog boxes with less functionality (e.g., no maximize/minimize control) can be used to provide pop-up capabilities. Controls provide the basic functionality of the application, while programmers can insert additional logic within the appropriate event handlers. For example, a drop-down combination box will automatically display its list and allow the user to select any element. An event handler is called when an item is selected, which can then execute additional code created by the programmer to perform some action based on which element was selected.

Alternatively, a Visual Basic component can have no user interface, but be available to other programs, providing objects that implement functionality. This allows for server-side processing or an add-in model.

The language is garbage collected using reference counting, has a large library of utility objects, and has basic object oriented support. Unlike many other programming languages, Visual Basic is generally not case sensitive. (String comparisons are case sensitive by default, but can be made case insensitive if so desired.)

Visual Basic spawned the first commercially viable reusable component market. There are thousands of 3rd party components available today from hundreds of vendors. Visual Basic makes it easy to build, deploy, use, and reuse components, however it is not as easy to use forms created for one application with another, due to the global nature of the language.

Controversy

Visual Basic is a controversial language; many programmers have strong feelings regarding the quality of Visual Basic. It was designed to be a simple language, and many features found in languages like C++ and Java are not found in Visual Basic. In the interest of convenience and rapid development, some features like compile time type-checking and variable declaration can be turned off. This leads to programmers praising Visual Basic for how simple it is to use, but also leads to frustration when programmers realize they need to use a feature that has been removed.

Many critics of Visual Basic explain that the simple nature of Visual Basic is harmful in the long run. First, it is often used to teach programming due to its simplicity, but learning to program in Visual Basic does not introduce the programmer to many fundamental programming techniques and constructs. This often leads to unintelligible code and workarounds. Second, allowing the programmer to turn off many of the checks and warnings that a compiler implements may lead to difficulties in finding bugs. Experienced programmers working in VB tend to leave such checks on.

Much criticism of Visual Basic is simply criticism of BASIC. A famous formulation by Edsger Dijkstra was, "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration [1] (http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html)." (Dijkstra was no less scathing about FORTRAN, PL/1, COBOL and APL.)

But many of the proponents of Visual Basic explain that the simple nature of Visual Basic is its main strength, allowing very rapid application development to experienced Visual Basic coders and a very slight learning curve for programmers coming from other languages. Additionally, Visual Basic applications can easily be integrated with databases, a common requirement.

Visual Basic is also a conglomerate of language features and syntax, with less consistency, but more tolerance, than many modern programming languages. Many language features like GoSub, On Error, and declaring the type of a variable by the last character in the name (i.e. str$) are legacies from Visual Basic's BASIC roots, and are included for backward-compatibility. Other characteristics include variable and subroutine names that are not case sensitive, and an underscore "_" must be used for a statement to span multiple lines. Some Visual Basic programmers perceive these as strengths needed to avoid case-sensitive compiler errors, and line-termination characters some languages require, usually semicolons.

The language continues to attract much praise and criticism, and it continues to cater to a large base of users and developers.

Programming constructs not present in Visual Basic

  • Object-oriented programming. Visual Basic has simple support for object-oriented programming but many common object-oriented features (such as inheritance) are not present in versions prior to Visual Basic .NET (2002). Visual Basic often uses different terminology, such as the 'property' concept, which is often referred to attributes and implemented using class variables in C++ or Java.
  • Threading support not present prior to Visual Basic .NET.
  • Exception handling with Try-Catch-Finally prior to Visual Basic .NET. Errors are handled by an "On Error Goto line" statement.
  • Built-in support for some bitwise arithmetic such as bit shifting.
  • Typecasting. VB instead has explicit conversion functions.
  • Equivalents to C-style pointers are very limited.
  • Visual Basic is limited to signed integers of 8 to 32 bits (8 to 64 bits in Visual Basic .NET and later), whereas many other languages provides built-in unsigned integers.
  • 32-bit and 64-bit Visual Basic is internally limited to UTF-16 strings, although it provides conversion functions to other formats (16-bit Visual Basic is internally limited to ASCII strings).
  • Visual Basic doesn't allow constant variables to contain an array. Therefore extra processing is required to emulate this.

While Visual Basic does not naturally support these features, programmers can, sometimes with difficulty, construct work-arounds to give their programs similar functionality if they desire.

Behaviors present in Visual Basic

VB has the following uncommon traits:

  • Variable array base. The first element in an array can either be referenced as the 0th or 1st element (controlled by the Option Base statement), leading to possible confusion when reading Visual Basic code. This lower bound is not limited to 0 or 1, because it can also be set by declaration. In this way, both the lower and upper bounds are programmable. In more subscript-limited languages, the lower bound of the array is not variable. This uncommon trait doesn't exist in Visual Basic .NET and VBScript.
  • Ability to run the application without performing a full compile or making an executable, allowing for edit-and-continue changes.
  • Relatively strong integration with the Windows operating system.
  • Banker's rounding as the default behaviour when converting real numbers to integers.

Visual Basic and VB.NET

Visual Basic .NET, VB.NET, is a backwards-incompatible upgrade of Visual Basic to Microsoft's .NET platform. Practically all of the above criticisms have been addressed with many of the missing features added. VB.NET has support for threading, advanced object oriented code, Try-Catch-Finally blocks, and zero-based arrays. Many new features (mainly from the .NET framework) have also appeared, like remoting, web services, 64-bit integers and ADO.NET.

VB.NET is also a fully-compiled language (as opposed to previous versions which could both compile and interpret the language). Programs require compilation even to be debugged. This resulted in a number of features being removed from Visual Basic, including the quick execution of programs, and the famous edit-and-continue feature (this feature will be restored in Visual Basic .NET 2005). Other significant features from past editions were also removed including control arrays.

Many of the original critics of Visual Basic now praise VB.NET for providing a "complete" language, while a few supporters of Visual Basic claim VB.NET has made the language too complicated and too hard to use for simple application development. Another criticism of VB.NET is the incompatibility and lack of similarity in syntax. VB.NET provides a wizard to help upgrade code, but many features are not converted properly. The wizard produces a list of places in the code where the upgrade is incomplete, but large projects have many thousands of such places requiring lots of programmer time to complete the upgrade. In particular the Variant data type, which was the default data type is no longer supported. Therefore, programs that did not declare all variables and/or those that depended on the Variant data type cannot be converted without significant effort. Programs written in VB.NET are not able to be feasibly converted back to VB6 code at all.

Some believe VB.NET support will diminish, with C# becoming the preferred language for .NET programming. This is despite the fact both compile to the same .NET Common Intermediate Language, with the programming language choice merely a matter of syntax preference.

Other criticisms of Visual Basic

  • Not being very portable. It is only available for Microsoft Windows, although a DOS version was marketed at one time. However, much of the code can run in Microsoft Office applications using VBA, including those applications running on Mac OS.
  • Being too big. Visual Studio is distributed on several discs, and executables require a 1.4 MB runtime library. However, while it is indeed distributed on several disks, Visual Studio is in essence a suite of applications, including Visual Basic, Visual C++, Visual Interdev, Visual SourceSafe, Visual J++ ( all in Visual Studio 6.0), and Visual C#, Visual J#, Visual C++, and Visual Basic .NET ( in Visual Studio .NET 2002 onwards). In reality, Visual Basic itself occupies only a large portion of one of the distribution discs.
  • Having bugs in the IDE. This is fixed to some extent by a series of service packs from Microsoft.
  • In VB6 and prior versions, the use of many core OS functions required directly calling into properly manually setup declarations of the Windows API. Due to the poor integration of VB with the native Windows API, this many times led to need for conversion code and low level memory "tricks" that were more complex than even that needed by "harder" or lower level programming languages like C.

Evolution of Visual Basic

VB 1.0 was introduced in 1991. The approach for connecting the programming language to the graphical user interface is derived from a system called Tripod, originally developed by Alan Cooper, which was further developed by Cooper and his associates under contract to Microsoft.

Timeline

  • Visual Basic 1.0 (May 1991) was released for Windows.
  • Visual Basic 1.0 for DOS was released in September 1992. The language itself was not quite compatible with Visual Basic for Windows, as it was actually the next version of Microsoft's DOS-based BASIC compilers, QuickBASIC and BASIC Professional Development System. The interface was barely graphical, using extended ASCII characters to simulate the appearance of a GUI.
  • Visual Basic 2.0 was released in November 1992. The programming environment was easier to use, and its speed was improved.
  • Visual Basic 3.0 was released in the summer of 1993 and came in Standard and Professional versions. VB3 included a database engine that could read and write Access databases.
  • Visual Basic 4.0 (August 1995) was the first that could create 32-bit as well as 16-bit Windows programs. It also introduced the ability to write classes in Visual Basic.
  • With version 5.0 (February 1997), Microsoft released Visual Basic exclusively for 32-bit versions of Windows. Programmers who preferred to write 16-bit programs were pleased to find that Visual Basic 5.0 was able to import programs written in Visual Basic 4.0, and it was not difficult to convert Visual Basic 5.0 programs to be compatible with Visual Basic 4.0. Visual Basic 5.0 also offered the ability to compile to native Windows executable code, eliminating the need for a runtime library.
  • Visual Basic 6.0 (Summer 1998) improved in a number of areas, including the ability to create web-based applications. VB6 will enter Microsoft's "non-supported phase" starting March 2008.
  • Visual Basic .NET was launched in 2001 along with the .NET Framework. Its language features are much richer than previous versions, although it is more complex. VB .Net is not backwards compatible, so many older VB programs must be modified to remove features incompatible with VB .Net (e.g., non-zero base arrays, the use of Variant, etc.)
  • In 2004 Microsoft released a beta version of Visual Studio.NET 2005 (codename Whidbey). This included a beta of version 2.0 of Visual Basic .NET
  • Also in 2004, Microsoft announced a return to offering support for the hobbyists that made Visual Basic so popular with the announcement of Visual Basic Express, and Visual Web Developer Express. Both are reduced feature versions of Visual Studio 2005 and support Visual Basic.NET 2.0.
  • In April 2005 Microsoft announced that support for non .NET versions of Visual Basic would end within a few years. The Visual Basic community instantly expressed its concern and lobbied users to sign a petition to keep the product alive. Microsoft refused to change their position on the matter.

Visual Basic and HyperCard

Putting Visual Basic into historical context invites comparison with HyperCard, a programming tool developed by Bill Atkinson, Dan Winkler, and their associates at Apple Computer and released in 1987. Both HyperCard and VB initially present the user with a "drawing" environment in which UI objects can be dragged, sized, captioned, and have a set of properties edited. Both connect a set of events, associated with the visual objects, to fragments of code. In both cases, the code is written in a programming language that is intended to cater to the novice and be easy to use. This is not to suggest that VB is a clone or copy of HyperCard. The relationship is more like that of C or Pascal to ALGOL; one can detect a family resemblance.

Unlike VB, HyperCard's programming language, HyperTalk, like COBOL before it (and AppleScript after it), consists of syntactically valid English sentences, such as "Get the number of card buttons." (Whether this actually makes it any easier to read, write, understand, or maintain than BASIC is arguable.)

The biggest difference, and the reason why VB was a breakthrough in a sense that HyperCard never was, is that VB produced applications that were virtually indistinguishable in look, feel, and general characteristics from Windows applications produced with traditional development tools. That is, it produced "real" Windows applications. HyperCard produced HyperCard stacks, not true Macintosh applications. HyperCard briefly spawned a limited cottage industry of commercial "stackware," rather like the former market in spreadsheet templates, but saw little commercial application (with notable exceptions: the fully commercial adventure game Myst was based on an elaborated version of HyperCard). HyperCard "stacks" were always recognizable as such.

HyperCard made a big impression when it was released in 1987, but for various reasons Apple did not follow it up vigorously or develop it much beyond what it was in 1987. By the year 2000 Apple had effectively abandoned it; it was officially discontinued in April 2004.

External links

Template:Wikibookspar


Template:Major programming languages smallbg:Visual Basic da:Visual Basic de:Visual Basic es:Visual Basic fr:Visual Basic ko:비주얼 베이직 hr:Microsoft Visual Basic it:Visual Basic he:Visual Basic hu:Visual Basic ms:Visual Basic nl:Visual Basic ja:Microsoft Visual Basic no:Visual Basic pl:Visual Basic pt:Visual Basic ru:Visual Basic simple:Visual Basic fi:Visual Basic sv:Visual Basic tr:Visual Basic zh:Visual Basic

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