Professional Documents
Culture Documents
Visual Basic
Lecture 1
Prof. Mounir Mabsout
Expert 1: Elsa Sulukdjian
Expert 2: Walid El Asmar
Introduction
Visual Studio 6.0: Collection of Microsoft Visual
development applications (Visual C++, Visual
J++, Visual Basic, etc)
VB is a programming language. 6 Versions
launched since its creation in the 90s.
Easy and powerful tool for developing
Windows applications in Basic. Bill Gates.
VB Development Environment
Integrated Development Environment (IDE):
visual environment to develop, run, test and
debug.
Controls: generally visual, and readymade
components, assigned a set of properties (I.e. Text
Box, Button, List Box, etc).
IntelliSense: Microsofts sophisticated completion
technology. It simplifies the coding process.
Event driven programming: flow of the
application dictated by the user actions (click of
a mouse, keystrokes, etc).
VB IDE
menu
bar
Toolbar
Project
Explorer
Toolbox Properties
window
Immediate
window Form
layout
VB IDE Components
Menu Bar: contains all commands needed to run VB
(File, Edit, View etc).
Toolbars: quick access to commonly used menu
commands.
Project Explorer: displays the projects components.
Toolbox: contains icons of the controls that can be
placed on the projects Forms to create the applications
interface.
Properties Window: Shows the property settings of
the selected control (size, caption, color, etc).
VB IDE Components (Contd)
Form Designer: Main window in which one
can design and edit the applications user
interface. In this window the user can enter and
edit the applications code. It displays two
windows: Form and Code window.
Form Layout: Shows the initial positions of the
forms in the application. It is useful in multiple
forms applications.
Immediate Window: Debugging tool.
Programming Steps
Step 1: Customize the windows that the user
sees. I.e. placing controls and components on
the layouts of the projects Forms.
Step 2: Decide on the events each control
should recognize.
Step 3: Coding the event procedures for those
events.
Variable Declaration
Visual Basic code works in two modes:
Implicit: does not require variable declaration
Explicit: requires variable declaration
Declare variables using
Dim VariableName As DataType
Example: Dim length As Integer
Dim greetings As String
Variable Types
Numeric: stores numbers
String: stores text
Variant: stores any type of data
Boolean: true/false
Date
Object
Implicit/Explicit
Implicit Example Explicit Example
Public Sub VBImplicit() Start code window by:
x=5 Option Explicit
y = Hello []
End Sub Public Sub VBExplicit()
Dim x As Integer, y As String
x=5
y = Hello
End Sub
Code
Form 2
Variable Scope (contd)
The same variable x is
Dim x As Integer
needed in both subroutines
and therefore is defined as Public Sub FirstSub()
a global variable (I.e. x=5
declaration outside subs) Dim y As Integer
End Sub