Computer Programming - Visual Basic
Computer Programming - Visual Basic
Chapter 1
Introduction to the Visual Basic
Language and Environment
What is Visual Basic?
• a tool that allows you to develop
Windows (Graphic User Interface - GUI)
applications.
• It is event-driven, meaning code remains
idle until called upon to respond to some
event (button pressing, menu selection, ...).
• It is governed by an event processor.
Event Processor
Example:
lblTime.Caption = "The current time is" &
Format(Now, “hh:mm”)
txtSample.Text = "Hook this “ + “to this”
Comparison operators
Operator Comparison
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
= Equal to
<> Not equal to
The result of a comparison operation is a
Boolean value (True or False).
Logical operators
Operator Operation
Not Logical not
And Logical and
Or Logical or
The Not operator simply negates an operand.
The And operator returns a True if both operands are
True. Else, it returns a False.
The Or operator returns a True if either of its operands
is True, else it returns a False.
Common Visual Basic Functions
• Format Date or number converted to a text
string
• Now Current time and date
• Sqr Square root of a number
• Str Number converted to a text string
• Time Current time as a text string
• Val Numeric value of a given text
string
Exercise 3
Savings Account
Visual Basic Branching
• Branching statements are used to cause
certain actions within a program if a certain
condition is met.