Visual Basic
Unit-1 Introduction to Visual BASIC: Introduction to Visual Basic, Features of VB, The
controls, The Properties, Events, Methods, Developing an Application, Design the User
Interface, Write code to Respond to User Input/Events
Introduction to Visual Basic (VB)
Visual Basic is a high-level, event-driven programming language developed by Microsoft.
It is mainly used for developing Windows-based applications with a graphical user interface
(GUI).
Features of Visual Basic
1. Easy to Learn-Uses simple English-like commands.
2. Graphical User Interface (GUI)-Applications can be created with windows, buttons,
textboxes, etc.
3. Event-Driven Programming-Code runs when events occur (such as button click).
4. Rapid Application Development (RAD)-Applications can be developed quickly.
5. Object-Oriented Support-Supports classes, objects, properties, and methods.
6. Database Connectivity-Can connect with databases like Microsoft Access and SQL
Server.
7. Debugging Tools-Helps find and remove errors easily.
The Controls in Visual Basic
Controls are objects placed on a form to accept input or display output.
Common Controls:
Label – Displays text.
TextBox – Accepts user input.
Command Button / Button – Performs an action when clicked.
CheckBox – Select yes/no options.
RadioButton / Option Button – Choose one option from many.
ComboBox – Drop-down list.
ListBox – Shows list of items.
PictureBox – Displays images.
Timer – Performs repeated tasks after intervals.
Properties in Visual Basic
Properties define the appearance and behavior of controls. Examples of Properties:
Property Meaning
Name Control name used in code
Text / Caption Text displayed
BackColor Background color
ForeColor Text color
Font Text style
Enabled Enable/disable control
Events in Visual Basic
Events are actions recognized by the program.
Common Events:
Event Meaning
Click Mouse click on control
Load Form starts
KeyPress Keyboard key pressed
MouseMove Mouse moved
Change / TextChanged Text changed
Timer Tick Timer event
Example: When user clicks a button, Click event occurs.
Methods in Visual Basic
Methods are actions performed by controls or objects.
Examples:
Method Use
Show() Display form
Hide() Hide form
Clear() Clear textbox
Focus() Move cursor to control
Close() Close form
Developing an Application in Visual Basic
Steps for application development:
Define problem.
Plan solution.
Design user interface.
Add controls to form.
Set properties.
Write code for events.
Run and test program.
Debug errors.
Save and deploy application.
Write Code to Respond to User Input / Events
In VB, code is written inside event procedures.
Example: Button Click Event
Private Sub Button1_Click()
[Link] = "Welcome to Visual Basic"
End Sub