Visual Basic Express for Kids
Table of Contents
1. Introducing Visual Basic Express
A Story About Bill and Paul 1-1
Let’s Get Started 1-3
Starting Visual Basic Express 1-5
Opening a Visual Basic Express Project 1-8
Running a Visual Basic Express Project 1-13
Stopping a Visual Basic Express Project 1-18
Stopping Visual Basic Express 1-19
Summary 1-20
2. The Visual Basic Express Design Environment
Review and Preview 2-1
Parts of a Visual Basic Express Project 2-2
Parts of the Visual Basic Express Environment 2-5
Starting a New Visual Basic Express Project 2-6
Main Window 2-9
Solution Explorer Window 2-8
Design Window 2-9
Toolbox Window 2-10
Properties Window 2-11
Moving Around in Visual Basic Express 2-12
Solution Explorer Window 2-12
Properties Window 2-14
Code Window 2-16
Summary 2-19
3. Your First Visual Basic Express Project
Review and Preview 3-1
Steps in Building a Visual Basic Express Project 3-2
Placing Controls on the Form 3-4
Example 3-5
Setting Control Properties (Design Mode) 3-7
Naming Controls 3-11
Setting Properties in Run Mode 3-12
How Control Names are Used in Event Procedures 3-14
Writing Event Procedures 3-16
Example 3-18
Summary 3-23
4. Project Design, Forms, Buttons
Review and Preview 4-1
Project Design 4-2
Saving a Visual Basic Express Project 4-4
On-Line Help 4-6
The Form Control 4-10
Properties 4-10
Example 4-11
Events 4-12
Typical Use of Form Control 4-13
Button Control 4-14
Properties 4-14
Example 4-16
Events 4-19
Typical Use of Button Control 4-19
BASIC – The First Lesson 4-20
Event Procedure Structure 4-20
Assignment Statement 4-22
Property Types 4-23
Comments 4-26
Project – Form Fun 4-27
Project Design 4-27
Place Controls on Form 4-27
Set Control Properties 4-28
Write Event Procedures 4-31
Run the Project 4-36
Other Things to Try 4-37
Summary 4-38
5. Labels, Text Boxes, Variables
Review and Preview 5-1
Debugging a Visual Basic Express Project 5-2
Syntax Errors 5-3
Run-Time Errors 5-5
Logic Errors 5-11
Label Control 5-12
Properties 5-12
Example 5-13
Events 5-15
Typical Use of Label Control 5-15
Text Box Control 5-16
Properties 5-16
Example 5-17
Events 5-18
Typical Use of Text Box Control 5-19
BASIC – The Second Lesson 5-20
Variables 5-20
Variable Names 5-21
Variable Types 5-22
Declaring Variables 5-23
Arithmetic Operators 5-26
Val and Str Functions 5-31
String Concatenation 5-34
Project – Savings Account 5-35
Project Design 5-35
Place Controls on Form 5-35
Set Control Properties 5-36
Write Event Procedures 5-39
Run the Project 5-42
Other Things to Try 5-43
Summary 5-46
6. UpDown Controls, Decisions, Random Numbers
Review and Preview 6-1
Numeric UpDown Control 6-2
Properties 6-2
Example 6-4
Events 6-5
Typical Use of Numeric UpDown Control 6-5
BASIC – The Third Lesson 6-6
Logical Expressions 6-6
Comparison Operators 6-7
Logical Operators 6-10
Decisions – The If Statement 6-15
Random Number Generator 6-20
Project – Guess the Number Game 6-23
Project Design 6-23
Place Controls on Form 6-24
Set Control Properties 6-25
Write Event Procedures 6-27
Run the Project 6-31
Other Things to Try 6-32
Summary 6-34
7. Icons, Group Boxes, Check Boxes, Radio Buttons
Review and Preview 7-1
Icons 7-2
Designing Your Own Icon with IconEdit 7-3
Assigning Icons to Forms 7-7
Group Box Control 7-8
Properties 7-8
Placing Controls in a Group Box 7-10
Example 7-11
Typical Use of Group Box Control 7-12
Check Box Control 7-13
Properties 7-13
Example 7-15
Events 7-15
Typical Use of Check Box Control 7-16
Radio Button Control 7-17
Properties 7-18
Example 7-19
Events 7-20
Typical Use of Radio Button Control 7-20
BASIC – The Fourth Lesson 7-21
Decisions – Select Case 7-21
Project – Sandwich Maker 7-26
Project Design 7-26
Place Controls on Form 7-27
Set Control Properties 7-28
Write Event Procedures 7-35
Run the Project 7-45
Other Things to Try 7-46
Summary 7-48
8. Panels, Mouse Events, Colors
Review and Preview 8-1
Panel Control 8-2
Properties 8-2
Typical Use of Panel Control 8-3
Graphics Using the Panel Control 8-4
Graphics Methods 8-4
Graphics Objects 8-5
Colors 8-7
Example 8-10
Pen Objects 8-11
Graphics Coordinates 8-13
DrawLine Method 8-14
Graphics Review 8-16
Example 8-17
BASIC – The Fifth Lesson 8-22
Mouse Events 8-22
MouseDown Event 8-23
Example 8-25
MouseUp Event 8-28
Example 8-28
MouseMove Event 8-29
Example 8-30
Project – Blackboard Fun 8-31
Project Design 8-31
Place Controls on Form 8-32
Set Control Properties 8-33
Write Event Procedures 8-37
Run the Project 8-44
Other Things to Try 8-46
Summary 8-50
9. Picture Boxes, Arrays
Review and Preview 9-1
Picture Box Control 9-2
Properties 9-2
Image Property 9-4
Example 9-6
SizeMode Property 9-11
Example 9-13
Events 9-16
Typical Use of Picture Box Control 9-17
BASIC – The Sixth Lesson 9-18
Variable Arrays 9-18
For/Next Loops 9-21
Procedure Level Variables 9-24
Shuffle Routine 9-26
Project – Card Wars 9-32
Project Design 9-32
Place Controls on Form 9-33
Set Control Properties 9-34
Write Event Procedures 9-39
Run the Project 9-47
Other Things to Try 9-48
Summary 9-49
10. Timers, Animation, Keyboard Events
Review and Preview 10-1
Timer Control 10-2
Properties 10-2
Events 10-3
Examples 10-3
Typical Use of Timer Control 10-11
BASIC – The Final Lesson 10-12
Animation – The DrawImage Method 10-12
Control Disappearance 10-17
Border Crossing 10-20
Image Erasure 10-25
Collision Detection 10-28
Keyboard Events 10-33
KeyDown Event 10-34
KeyPress Event 10-37
Project – Beach Balls 10-42
Project Design 10-42
Place Controls on Form 10-43
Set Control Properties 10-44
Write Event Procedures 10-48
Run the Project 10-57
Other Things to Try 10-58
Summary 10-60
Bonus Projects
Preview B-1
Project 1 – Stopwatch B-2
Project 2 – Tic-Tac-Toe B-8
Project 3 – Dice Rolling B-20
Project 4 – State Capitals B-26
Project 5 – Memory Game B-37
Bonus Project – Pong! B-53