0% found this document useful (0 votes)
54 views25 pages

Zak - Ch01 Theory

Programming with Microsoft visual basic chapter 1 notes

Uploaded by

Abednego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views25 pages

Zak - Ch01 Theory

Programming with Microsoft visual basic chapter 1 notes

Uploaded by

Abednego
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Programming with Microsoft Visual Basic 2017

Chapter 1
An Introduction
to Visual
Studio 2017
and Visual
Basic
Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly
accessible website, in whole or in part
FOCUS ON THE CONCEPTS LESSON

Concepts covered in this lesson:


• F-1 Computer programming terminology
• F-2 The programmer’s job
• F-3 The Visual Basic programming language
• F-4 The Visual Studio IDE
• F-5 Assigning names to objects

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-1 Computer Programming Terminology
(1 of 2)
• In essence, the word programming means giving a
mechanism the directions to accomplish a task.
• A set of instructions that tells a computer how to
accomplish a task is called a computer program or,
more simply, a program.
• Programs are written by programmers using a variety
of special languages called programming languages.
• An integrated development environment (IDE) is an
environment that contains all of the tools and features
you need to create, run, and test your programs.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-1 Computer Programming Terminology
(2 of 2)
• A graphical user interface (or GUI) is what the person
using your program (referred to as the user) sees and
interacts with while your program is running.
• Program instructions (code) is what we code to let the
program do a job.
• The user interface and its program instructions are referred
to as an application.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
To run the Good Morning application:

• Use Windows to locate and then open the


VB2017\Chap01 folder on your computer’s hard disk or
on the device designated by your instructor.
• Double-click Good Morning.exe in the list of
filenames.
• The application’s user interface appears on the screen
with a blinking “It’s time to get up!!!!” message.
• Click the Exit button to close the application.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-2 The Programmer’s Job

• The software developer/analyst will meet with the


user and then outline the problem specification for the
programmer.
• The programmer meets with the person responsible
for describing the problem (analyst).
• After the planning is complete, the programmer will
translate the solution into computer instructions—a
process called coding.
• The programmer then will test the program rigorously
with sample data to make sure it works both correctly
and to the user’s satisfaction.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-3 The Visual Basic Programming
Language
• Visual Basic is an object-oriented programming
language, which is a language that allows the
programmer to use objects to accomplish a program’s
goal.
• In object-oriented programming, or OOP, an object is
anything that can be used.
• Every object in an object-oriented program is created
from a class, which is a pattern that the computer
uses to create the object.
• An object created from a class is called an instance of
the class.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-4 Object vs Class

• A class specifies 2 things:


– Attribute / properties
 A button has a name and text
 The person “class” specifies that a person has a name,
surname and birth date
– Behavior
 The person “class” specifies that a person can run and talk and
walk
 A button is clickable
• An object created from the class will have the attributes
and behavior specified in the class.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-5 Object vs Class

• An object created from the class will have the attributes


and behavior specified in the class.
– Attribute / properties
 A button has a name (btnShow) and text (Show picture)
 The person “class” specifies that a person has a name (Ben),
surname (Motloung) and birth date (2000/01/30)
– Behavior
 btnShow is clickable and we can specify what must happen
when it is clicked

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
To run the applications (1 of 3)

• If necessary, open the VB2017\Chap01 folder.


• Double-click Payment.exe
• After a few moments, the Monthly Payment Calculator
application appears on the screen. The interface
contains a text box, a list box, buttons, radio buttons,
and labels.
• First, you will use the application to calculate the
monthly payment for a $15,000 loan at 3.5% interest
for five years. Type 15000 in the Principal text box.
Scroll down the Interest list box and then click 3.50%.
Finally, click the Calculate button.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
To run the applications (2 of 3)

• The application indicates that your monthly payment


would be $272.88.
• Next, you will determine what your monthly payment
would be if you borrowed $4,500 at 2.75% interest for
four years. Type 4500 in the Principal text box, click
2.75% in the Interest list box, click the 4 years radio
button, and then click the Calculate button.
• Click the Exit button to close the application.
• Now double-click Einstein.exe. Click the Show
equation button to display Einstein’s famous equation.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
To run the applications (3 of 3)
• Click the Hide equation button to hide the equation,
and then click the Exit button to close the application

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-4 The Visual Studio IDE (1 of 4)

• The Visual Studio IDE contains many different


windows, each with its own special purpose.
• The designer window is where you create (or design)
your application’s GUI.
• A form is the foundation for the user interface in an
application created for the Windows environment.
• You use the Toolbox window to add other objects,
called controls, to the form.
• Each tool listed in the Toolbox window represents a
class.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-4 The Visual Studio IDE (2 of 4)

• Each object has a set of attributes that determines its


appearance and behavior.

• The attributes, called properties, are listed in the


Properties window when the object is selected in the
designer window.

• The Solution Explorer window displays a list of the


projects contained in the current solution and the items
contained in each project.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-4 The Visual Studio IDE (3 of 4)

• The Solution Explorer window indicates that the


Einstein Solution contains the Einstein Project, which
contains several items:

– The Einstein.png and Equation.png items are the names


of files on your disk.

– The Main Form.vb file stores the program instructions


(code) that tell the three buttons how to respond when
the user clicks them.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-5 Assigning Names to Objects (1 of 2)

• Each object has a set of properties attached to it.


• One of the most important of these properties is the
Name property.
• This is because you use the Name property to refer to
the object in code.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
F-5 Assigning Names to Objects (2 of 2)

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Assignment Statements and Comments
(1 of 7)
• You can set an object’s properties during design time,
which is when you are building the interface.

• You can also set an object’s properties during run


time, which occurs while the application is running; you
do this by using an assignment statement.

• An assignment statement is one of many different


types of Visual Basic instructions.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Assignment Statements and Comments
(2 of 7)
• The operator indicates that the property is a member of
the object. (property belongs to object)
• The equal sign in an assignment statement is called the
assignment operator.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Assignment Statements and Comments
(3 of 7)
Create a UI:

Purpose: The show and hide buttons must make the


View button appear and disappear

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Assignment Statements and Comments
(4 of 7)
• Code a comment before the class (program, author,
date)
• Code an event procedure for btnShow (a click event):
– btnView.Visible = True
– (This stores true in btnView’s visible property as soon as
the instruction is executed (run). If the button is visible, it
is displayed)
• Code an event procedure for btnHide (a click event):
– btnView.Visible = False
– (This stores false in btnView’s visible property as soon as
the instruction is executed (run). If the button is NOT
visible, it disappears)

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Assignment Statements and Comments
(7 of 7)

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Summary (1 of 3)
• Programs are the step-by-step instructions that tell a
computer how to perform a task.
• Programmers use various programming languages to
communicate with the computer.
• Programmers are responsible for translating a
problem’s solution into instructions that the computer
can understand.
• Programmers rigorously test a program before
releasing the program to the user.
• An object-oriented programming language, such as
Visual Basic, enables programmers to use objects
(e.g.,

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Summary (2 of 3)
• check boxes and buttons) to accomplish a program’s goal.
An object is anything that can be used.
• Every object in an object-oriented program is instantiated
(created) from a class,
• A class is a pattern that tells the computer how the object
should look (data) and behave (do). An object is referred to
as an instance of the class.
• The four windows you use most often when designing
application’s GUI are:
– the designer Window,
– Toolbox Window,
– solution explorer Window,
– properties Window.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part
Summary (3 of 3)

• Each tool (control) in the toolbox represents a class.


• Each object has a set of properties that determines its data
(appearance)
• Each object has behavior as is specified by the class.

• Windows applications in Visual Basic are composed of


solutions, projects, and files.
• You enter your application’s program instructions in the
Code Editor window.
• An object’s name, which is entered in its Name property,
can be used to refer to (use) the object in code.

Copyright © 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a
publicly accessible website, in whole or in part

You might also like