Visual Basic Tutorial
Visual Basic was created by Microsoft to make it easier to write programs for the Windows computer operating system. Visual Basic allows you to move visual elements and design applications by pointing, dragging and clicking with your mouse and only writing additional lines of code for more functionality. This is why it's called "Visual" Basic.
-
The Visual Basic Environment
-
Visual Basic is a combination of visually arranging controls on a form that identify attributes and actions of those components and consist of many windows that fasten your programs together. There are six common windows displayed on start-up that make up the Visual Basic environment every programmer should be familiar with:
Project Window
The Project window holds your application's forms, controls, code and all related elements. All files you create will default into this window.Properties Window
The Properties window is the behavior of a control, form or other Visual Basic element. If you want to customize the look or behavior of a control, change that control's size or font.Form Window
The Form window is where you do most of your work and the background where you place all of your program's controls, text and data-entry boxes.Toolbox
When you want a specific tool, you'll select one from the Toolbox. The four basic tools from the Toolbox are the Pointer, Label, Command Button and Text Box.Menu Bar
Many of the Visual Basic menu options are just like the ones used in other Windows programs. The Menu commands are File, Edit, View, Run, Debug, Options, Window and Help.Toolbar
The Toolbar, located below the Menu bar, offers shortcuts. The Toolbar provides many menu commands such as "Open existing project," "Save current project" and "Create new form."
Visual Basic Code
-
A program can be created with Visual Basic without the programmer having to write many lines of code or instructions. For example, you may want to change your Form's background color when the user clicks the Command Button. To do so, double-click the Command Button to open the code window. Type the following line between the Sub and the End Sub statements:
Sub Command1_Click()
Form1.BackColor = QBColor()
End SubThe first line of every subroutine, set of instructions, is Sub SubName, and the last line is always End Sub. The parentheses indicates a function or return value.
Visual Basic is an event driven programming language. Anything your user does, such as clicking a button or pressing a key, the application will always respond to those events.
-