Introduction to Visual Basic
Visual Basic is a Visual programming tool that allows you to develop Windows (Graphic User Interface – GUI) and browser based applications. These applications have a simple user interface and are easier for user to use.
Visual Basic is event-driven programming language, meaning code remains idle until called upon to respond to some event (button click, menu selection, keypress, Lost_Focus and so on). Visual Basic is governed by an event processor. Nothing happens until an event is detected. Event is made or triggered by the user, example by clicking on a Visual Basic Component. Once an event is detected, the code corresponding to that event (event procedure) is executed. Program control is then returned to the event processor.
Figure 1 Block Diagram of Event Driven Programming
Figure 2 Structure of Visual Basic Application
Components of Microsoft Visual Basic IDE
Visual Basic Application is made up with collaboration of these components:
- Forms – Forms are the Windows that you create for user interface for application. Besides standard forms, Visual Basic also supports Multiple Document Interface (MDI) forms, as well as a whole number of predefined forms.
- Controls – Controls are the inbuilt graphical features drawn on forms to allow user interaction. These controls are provided by Visual Basic, and can be drawn by dragging from tool box. Text boxes, labels, scroll bars, command buttons, etc. are examples of controls. The control hidden in tool box can be added by adding components. (Project > Components) (Forms and Controls are objects.)
- Properties – Every characteristic of a form or control is specified by a property. Example properties include names, captions, size, color, position, and contents. Visual Basic applies default properties. You can change properties at design time or run time.
- Methods – Methods are built-in procedure that can be invoked to impart some action to a particular object. Show, Hide, Move, Load, Unload, etc are some methods used in Visual Basic 6.
- Event Procedures – Event procedures are code related to some object. This is the code that is executed when a certain event occurs. Code written under the Click event of the Command1 button is the event procedure that will be executed when the button is clicked.
- General Procedures – General procedures are code not related to objects. This code is written by programmer to eliminate the writing of mostly occurring group of statements or functions. This code is executed when called by the application.
- Modules – Modules are collections of code and data that function something like objects in Object-Oriented programming (OOP), but without defining OOP characteristics like inheritance, polymorphism, and so on. The point behind modules is to enclose procedure and data in a way that hides them from the rest of the program. A module also contains general procedures, variable declarations, and constant definitions used by application.
Visual Basic application can be viewed in three distinct states: design, execution, and break.
In the design state, you can edit the user interface or attach codes to the application. In this state, programmer uses there longest time available for project. All the windows of the IDE and its components are available to you. Design state is composed of three steps:
- Draw the user interface.
- Assign Properties to the controls.
- Attaching code to the controls.
In the execution state, the application is running. Only a few commands are available, and none of the windows of IDE are available. You can neither edit the user interface nor add code to an application while it’s running. This state is also called run state. This state is some what like testing state of the application, errors in application can be known by this state but debugging activities are not included in this state.
In the break state, the application’s execution has been interrupted temporarily and can resume when you press F5 or choose Run > Continue. The immediate window is activated, and you can edit the code and issue commands in it. However, you can’t edit the user interface. So, in this state testing and debugging of the application is done at same time by breaking the application.
More Chapters/ Tutorials on Visual Basic 6
This Chapter includes more detailed tutorial on Visual Basic and walkthrough
This chapter includes a full tutorial on “Building Math Calculator as First Visual Basic Project”
You’ll know more about the Development Environment of Microsoft Visual Basic IDE.
Learn more about fundamental visual interface components and more gui components used in Visual Basic Development Environment.
Working with Visual Basic Controls guides different ways of using various Controls interfaces like textbox, combobox and many more with their various event handler.