VisualBasicLanguage (acronym: "VB") is a programming language that is both easy to learn and suitable for RapidApplicationDevelopment. It is designed and implemented by Microsoft and is based on the older BasicLanguage.
Although VB may be a fun language to program in sometimes, most dislike it because usually lacks the challenges found in other languages and because it can encourage bad programming habits. If you are looking for a fast way to write Windows GUI applications, but do not like BasicLanguage, you may want to look into DelphiLanguage (based on PascalLanguage)
Everything on that page only applies to older versions of VB: VB6, VB5, VB4, ... The newest implementation of a language called "Visual Basic" is Visual Basic .NET. It shares the same syntax as VB but fixes a number of the shortcommings of older versions.
There are several interesting aspects of VB, not necessarly all good; that being said:
- Confusing mixture of 0-based and 1-based collections and arrays; older VB uses 0-based whereas newer VB uses 1-based.
VB defaults to 0-based arrays. You could use 1-based array by declaring array like that: Dim array(1 To 10) As String. However, collections have always been 1-based. Microsoft only knows why.
- Language bound to the IDE. You could never use VB without the IDE provided by Microsoft.
- 'Magical' way of managing events on forms.
Private Sub Command1_Click() MsgBox "Hello, world" End Sub
This apparently ordinary function automatically gets attached to the click event of the object called 'Command1'. That is only if the 'Command1' object has a Click event to attach too. In that sense, the binding of the event to the function is apparently 'magical', done by the IDE or the runtime.
Very limited object-oriented programming features even when compared to ordinary OO languages like Java and C++.
- No inheritance
- Classes needed to be declared in IDE specific modules called 'Class Modules'.
- 1 constructor/destructor per class. The constructor could not use any parameters.
Difference in behavior between variables referencing objects and ordinary variable. You need to use Set var = obj to affect objects to variables. Ordinary variables used standard var = value affectation. -- Is this really bad practice? If yes, why? Please fill-in. -- FrancoisDenisGonthier
In this case, it is good practice, because VB does not have explicit pointer variables, thus the need to differentiate. -- DavidYust
- Improper shortcircuting of compound statements:
Dim blnFalse as Boolean: blnFalse = False
If blnFalse And ["MsgBox"]("Testing","Should you see this message box?", vbYesNo) = vbYes Then
'HUH? NO, YOU SHOULD NOT SEE THAT MESSAGE BOX *IF* PROPER SHORTCIRCUTING WERE TO HAPPEN
End IfVisual Basic has two derivatives, VBScript and VBA. VBScript is essentially the VB programming language without the GraphicalUserInterface programming facilities and ide, while VBA (or Visual Basic for Applications) is a version of VB integrated with Office. VBScript is the dominant language used to write Active Server Pages code.
So far this document has disregarded Visual Basic .NET, where most of the issues here have been resolved. It has all the OO features you would find in C++ or Java. Using 'option strict' will make it so your code will not compile unless it is type-safe. Classes no longer are in 'IDE Specific' class modules, everything resides in a class, much like Java. Constructors and Destructors are allowed to have parameters and can even be overloaded. Object Bindings to events are not 'magical' they are explicity bound to functions in your code. While VB .net still allows you to code like you were in VB6 don't be tempted to do so, turn on option strict and option explicit and you should be pretty well off. -- DavidSnider
Option Explicit exists in VB6 and below as well, and is a very good (read: almost mandatory) option to have on unless you plan to do a lot of debugging. -- DavidYust
