CSC301 - Chapter 1
CSC301 - Chapter 1
Most Visual Basic 2017 programs are event-driven programs that communicate
with the user through a graphical user interface (GUI)
The GUI usually consists of a window, containing a variety of objects
Defines how elements look and function
An event means the user has initiated an action that causes the program to perform
a type of processing in response to that action
EVENT-DRIVEN
COMPUTER PROGRAMS
WITH A GRAPHICAL USER
INTERFACE (2 OF 2)
For example:
A user might enter
data into the
program and then
click a button
VISUAL STUDIO 2017 WINDOW (1 OF 3)
VISUAL STUDIO 2017 WINDOW (2 OF 3)
The following elements help you to use the Visual Studio 2017 Window:
Title bar: The title bar identifies the window and the application open in the window
Menu bar: The menus contain lists of commands that allow you to create, edit, save, print, test,
and run a Visual Basic program and to perform other functions
Standard tool bar: The Standard tool bar contains buttons that execute frequently used
commands such as Open Project, New Project, Save, Cut, Copy, Paste, and Undo
Toolbox: The toolbox contains .NET components that help you develop the GUI program
Main work area: The main work area contains the item you are currently developing
Solution Explorer: The Solution Explorer window displays the elements of the Visual Basic
solution
OBJECTS MODEL
Class = automobile
Properties of automobile class= make, model, color, engine, year
Object = Each individual auto is an object.
Object is also an Instance of the automobile class.
A control is specific type of object that usually appears in a program’s graphical user
interface
The window that contains the other elements is known as a Form control
The small boxes that accept input are known as TextBox controls
The areas that simply display text are known as Label controls
The buttons that perform operations when clicked with the mouse are known as
Button controls
TYPES OF CONTROLS
Form
Label TextBox
Label TextBox
Label Label
Button Button
VISUAL BASIC CONTROLS
THE NAME PROPERTY
Form1
Label1 txtHourWorked
Label2 txtPayRate
Label3 lblGrossPay
btnCalcGrossPay btnClose
CONTROL NAMING RULES AND CONVENTIONS
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.
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 (" ")
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( )
RUN, SAVE, MODIFY, PRINT, TEST, DEBUG, AND EXECUTE
Run Project
Open Debug Menu, Start Debugging. "Help is always available from the
Help Menu or by pressing F1."
Start Debugging button on the toolbar.
Press F5, the Start Debugging command.
Save Project — File Menu, Save All.
Modify Project if needed.
Print the Code.
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.
FINDING AND FIXING ERRORS
Syntax Errors
Breaks VB’s rules for punctuation, format, or spelling
Smart editor finds most syntax errors, compiler finds the rest.
The editor identifies a syntax error with a squiggly blue line and you can point to an error to
pop up the error message.
You can display the Error List window and line numbers in the source code to help locate the
error lines.
Run-Time Errors
Statements that fail to execute, such as impossible arithmetic operations
Logic Errors
Project runs, but produces incorrect results.
END OF CHAPTER 1