Visual Basic is a high-level programming language with a rich command set. Its heritage as an instructional language makes Visual Basic suitable for a wide range of programming tasks. Over the years, vendor refinements and enhancements have addressed and corrected most of the problems and shortfalls of the original Dartmouth specifications. Some key elements are discussed below.
Specific variable declarations are not required in the original BASIC language. This option remained in Visual Basic through Version 6.0. Although using variables that are not specifically declared may speed program development somewhat, they are difficult to manage and often lead to errors. Any variable not specifically declared is created with the Variant data type, which is very inefficient. Good programming practice dictates that variables be specifically declared before use.
String is a field of at least 12 bytes and a maximum limited only by the computer hardware. It is capable of holding from 0 to approximately 2 billion Unicode characters.
The variant data type available in Visual Basic 6.0 and earlier versions does not exist in Visual Basic.NET. Variables declared in the Variant data type can hold integers, real numbers, or character strings. Variables created via the automatic variable declaration mechanism are of the data type Variant. Elimination of the Variant data type from Visual Basic.NET made support of the automatic variable declaration option impossible.
Given the Variant data type’s inefficient use of memory, the additional overhead needed to actively configure memory usage to accommodate both numeric and character string data, and the development problems discussed above, elimination of the Variant data type and the automatic variable declaration option from Visual Basic.NET is not considered a significant loss.
Visual Basic offers a complete set of decision and repetition control structures. Decision structures allow the program to compare data items to determine which statements to execute. Visual Basic includes the If Else, and Select Case decision control structures. Repetition structures allow the program to repeat groups of statements, called blocks, if certain conditions are met.
Visual Basic includes the pretest While loop, the pretest until loop, the posttest While loop, the posttest until loop, and the Counter Controlled loop. These control structures are not unique to Visual Basic. Consult the bibliography for text and reference books that cover the general function and specific syntax of Visual Basic’s control structures.
The Toolbox contains the control classes that can be included in a Visual Basic program. It contains controls commonly used in Windows programs. Additional controls are available from other Microsoft sources and from third party vendors. A control is selected from the toolbox and placed on the form. Each control is given a unique name. Controls in Visual Basic are object classes, which have properties and methods defined for them. These properties and methods are inherited by the control when it is created. Properties and methods associated with a specific control are accessed using the Operator is used to separate the control name from the property or method being accessed. For example
The Combo Box control is a combination of the List Box and Text Box controls. The Combo Box is a List Box with a Text Box affixed to the top. The Text Box portion remains visible whereas the List Box portion can be displayed or hidden. An item selected from the Combo Box list is displayed in the Text Box. In many applications, the user does not need to see the contents of the list once an item has been selected. The Combo Box displays the complete list while a selection is made, then hides the list to save space on the form. The Text Box portion of the Combo Box remains visible, keeping the selected item visible on the form.