Visual Basic Intro
Visual Basic Intro
Announcements
Thursday, Oct 9th, 7:30PM, C106
Lloyd Douglas (NSF)
Diversity in Science-Who needs it?
5 extra credits.
Programming language
Programming is writing instructions
for a computer.
Level of programming languages
Machine language 0s and 1s
Intermediate languatge assambly
language.
High level language BASIC, C++
Interpreting or compiling
How do computers handle the high
level language?
Read and Interprete the code line by line
with an program called interpreter, e.g.
BASIC.
Translate the language to machine code
(executable files) with a program called
compiler and run the program, e.g.
C++.
Visual basic has both Interpreter and Compiler.
History of BASIC
Basic --- Beginners' All-purpose
Symbolic Instruction Code (May,
1964)
MS-BASIC 2.0 (July, 1975)
Visual Basic 1.0 (May,1991)
Visual Basic 6.0 (July 1998)
Step 4a:Compiling
Compiling converts Visual Basic
source code to executable machine
language - instructions the processor
can understand (1s and 0s)
Creates .exe file
Advantage:
Fast and small
Disadvantage:
Debugging is inconvenient.
Disadvantage:
Slow
Step 5: Debugging
Debugging is removing the
functional errors from your program
Running tells you where there are
errors
Go back to source code and fix errors
Save and re-run
Repeat until errors are gone
VB programming
Project
Form 1
Text box
Picture box
Form 2
Form 3
Button
Button
Text box
Objects
Objects
Definitions
Form contains the Main Program
Controls are user interface elements
(text boxes, commands) in the Form
Forms and Controls are referred to as
OBJECTS
Objects have PROPERTIES (features
you can change)
Objects in VB
Everything in VB is
objects, forms,
buttons,
Three elements of
objects.
Properties
Methods
Event handlers.
VB object
Properties (size,
Caption)
Methods (Print)
Event Handler
(Command1_Click())
Object: Dog
Properties
Height, weight, color, emotion (friendly,
hostile)
Methods
Barking, biting, wagging, singing
Event handlers
Owner coming in: call wagging, call singing,
emotion=friendly;
Intruder coming in: call barking, call biting,
emotion=hostile.
Important Controls
Text Boxes area where you enter
text
Text Boxes
Properties:
Name (of object)
Text (the words)
Alignment (left, right, middle)
Appearance
BackColor (background)
BorderStyle
Font
FontColor
Command Button
Properties:
Name
BackColor
Style (This controls the backcolor)
Caption
Picture Boxes
Properties
Name
Picture
Methods
Print
Definitions
Forms
properties
properties
properties
properties
Methods
properties
properties
properties
Handlers
Picture Box
properties
properties
properties
properties
properties
properties
properties
Methods
properties
properties
Command
Objects
Button
properties
properties
properties
Methods
properties
properties
Textbox
properties
properties
properties
properties
properties
properties
properties
Methods
properties
Label
properties
properties
properties
properties
properties
properties
properties
Methods
properties
properties
Properties
Text box
Methods
Event Handler
User
Message
Dispatching
Block
Properties
Button
Methods
Event Handler
Properties
Picture
Box
Methods
Event Handler
Making It Do Something
Want program to change on an
Event
Events:
MouseDown
MouseUp
Click
Sub Procedure
Two Objects: Text1 and Command1
Sub Procedure:
Private Sub Command1_Click()
Text1.FontSize = 18
End Sub
Sub Procedure
Private Sub CommButt_Click()
Text1.FontSize = 18
Text1.BackColor = vbBlue
Command1.Caption = "Get Some Now"
End Sub
Homework
Read Chapters 1 & 2 in book