Visual Basic
Visual Basic
VISUAL
BASIC
A Brief Hist ory of
Basic
· Language developed in early 1960's at
Dartmouth College:
B (eginner's)
A (All-Purpose)
S (Symbolic)
I
(Instruction)
C (Code)
· Answer to complicated programming
languages (FORTRAN, Algol, Cobol ...).
First timeshare language.
A Brief History of Basic
. In the mid-1970's, two college students
write first Basic for a microcomputer
(Altair) - cost $350 on cassette tape.
You may have heard of them:
Bill Gates and Paul Allen!
Private Statement
- variable can only be used in the form it is
declared
Module-level – variables declared in
the declarations section of the module
- available only for the control in the form
Types of Constants
vbTrue
vbBlack
User-Defined Constants –
defined by programmers that write the
code
Const Pi = 3.1416
Const Max_Num = 100
Note that the order of operators is determined by the usual rules in programming.
When a statement includes multiple operations the order of operations is:
Parentheses ( ), ^, *, /, \, Mod, +, -
Logical operators
Operator Definition Example Result
= Equal to 9 = 11 False
> Greater than 11 > 9 True
< Less than 11 < 9 False
>= Greater or equal 15 >= 15 True
<= Less or equal 9 <= 15 True
<> Not equal 9 <> 9 False
AND Logical AND (9 = 9) AND (7 = 6) False
OR Logical OR (9 = 9) OR (7 = 6) True
Select Case
Can be used as an alternative to the If...Then...Else structure, especially
when many comparisons are involved.
Do While condition
statements
Loop
First, the condition is tested; if condition is True, then the statements are
executed. When it gets to the Loop it goes back to the Do and tests
condition again. If condition is False on the first pass, the statements are
never executed.
For...Next