Professional Documents
Culture Documents
1-1
Chapter
McGraw-Hill
Chapter Objectives (1 of 2)
Describe the process of visual program design and development Explain the term object-oriented programming Explain the concepts of classes, objects, properties, methods, and events List and describe the three steps for writing a Visual Basic project Describe the various files that make up a Visual Basic project
1-3
Chapter Objectives (2 of 2)
Identify the elements in the Visual Studio environment Define design time, run time, and debug time Write, run, save, print, and modify your first Visual Basic project Identify syntax errors, run-time errors, and logic errors Use Auto Correct to correct syntax errors Look up Visual Basic topic in Help
1-4
1-5
(1 of 2)
In VB you will work with objects, which have properties, methods, and events. Each object is based on a class. Objects equate to Nouns
Forms are windows Controls are components contained inside a form
1-8
Object Model
(2 of 2)
Methods = start, stop, speedup, slowdown Events = car arrives, car crashes
1-10
VB Application Files
One Solution Filethink of one solution file equals one project Solution User Options File .sln .suo
Form Files
Resource File for the Form Project Files
.vb
.resx .vbproj
.vbproj.user
.app.config
Once a project is run several more files are created by the system. The only file that is opened directly is the solution file.
1-13
1-15
1-16
Toolbars Document Window Form Designer Solution Explorer Window Properties Window Toolbox Help
1-17
ToolBox
You can scroll to view more controls To sort the tools in the toolbox:
Right-click the toolbox and select Sort Items Alphabetically from the context menu (shortcut menu).
1-18
Modes
Design Time--used when designing the user interface and writing code Run Time--used when testing and running a project Break Time--if/when receiving a run-time error or pause error
1-19
3
1-20
After the user interface is designed, the next step is to set the properties
1-21
Setting Properties
Label 1 Name Text messageLabel leave blank pushButton Push Me
exitButton Exit
helloForm Hello World by your name
1-22
1-23
1-25
Remark Statement
Also known as Comment, used for documentation; every procedure should begin with a remark statement providing explanation Non-executable Automatically colored Green in Editor Begins with an apostrophe ( ' )
On a separate line from executable code At the right end of a line of executable code
'Display the Hello World message.
1-26
Assignment Statement
Assigns a value to a property or variable Operates from right to left- the value appearing on the right side of the equal sign is assigned to the property named on the left of the equal sign Enclose text strings in quotation marks (" ")
1-27
Ending a Program
Methods always have parentheses (this will help you
distinguish them from Properties which never have parentheses)
To execute a method of an object you write: Object.Method() Current Form may be referenced as Me
Me.Close( )
1-28
Editor Window
Declarations Section Class list Method list
1-29
(F5)
(CTRL+F5)
Save Project - File Menu, Save All Modify Project if needed "Help is always available from the Print the Code Help Menu or by pressing F1." Correct any Errors and Rerun
When you start executing your program, the first step is called compiling, which means that the VB statements are converted to Microsoft Intermediate Language (MSIL). Your goal is to have no errors during the compile process: a clean compile.
1-30
1-31
Run-Time Errors
Statements that fail to execute such as impossible arithmetic operations
Logic Errors
Project runs but produces incorrect results
1-32
1-33
The Help system display is greatly changed and improved in Visual Studio 2005. You view the Help topics in a separate window from the VS IDE, so you can have both windows open at the same time.
1-35