Tải bản đầy đủ (.pptx) (49 trang)

microsoft visual basic 2015 chapter 03

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.22 MB, 49 trang )

Microsoft Visual Basic 2015
CHAPTER THREE

Program Design and
Coding


3

Objectives

►Change the color properties of an object
►Add images to a PictureBox object
►Locate and save an image from the web
►Import an image into the Program Resources
folder
►Size an image

Chapter 3: Program Design and Coding

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

2


3

Objectives


►Set the Visible property in the Properties window
►Set the Enabled property in the Properties
window
►Run a Visual Basic 2015 program
►Enter Visual Basic 2015 code
►Understand Visual Basic 2015 code statement
formats

Chapter 3: Program Design and Coding

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

3


3

Objectives

►Use IntelliSense to enter Visual Basic 2015 code
statements
►Use code to set the Visible property of an object
►Use code to set the Enabled property of an object
►Enter comments in Visual Basic 2015 code

Chapter 3: Program Design and Coding

© 2016 Cengage Learning®. May not be scanned, copied

or duplicated, or posted to a publicly accessible website, in
whole or in part.

4


3

Objectives

►Correct errors in Visual Basic 2015 code
►Write code to use the Close() procedure
►Print code
►Prepare an event-planning document

Chapter 3: Program Design and Coding

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

5


3

BackColor and ForeColor Properties

►Tap or click the Windows Form object to select it
►If necessary, scroll in the Properties window until

the BackColor property is displayed, and then tap
or click the right column of the BackColor property
►Tap or click the BackColor arrow. Then, tap or
click the Web tab to display the Web tabbed page
►Scroll to display the color you wish to apply
►Tap or click the color you wish to apply on the
color list

Chapter 3: Program Design and Coding

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

6


3

BackColor Property

Chapter 3: Program Design and Coding

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

7



3

Locating and Saving an Image
from the Web

►Open your web browser and navigate to the
webpage containing the image you want to save
►Press and hold or right-click the image, tap or
click Save Picture As, and then navigate to the
location on your computer where you store
downloaded files
►Click the Save button to save the image

Chapter 3: Program Design and Coding

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

8


3

Locating and Saving an Image
from the Web

Chapter 3: Program Design and Coding

© 2016 Cengage Learning®. May not be scanned, copied

or duplicated, or posted to a publicly accessible website, in
whole or in part.

9


3

Importing the Image
into the Program Resources Folder

► With Visual Studio 2015 and the desired program open,
select the desired PictureBox object by tapping or clicking
it. Scroll in the PictureBox Properties window until the
Image property is visible. Tap or click the Image property
name in the left list of the Properties window
► Tap or click the ellipsis button in the right column of the
Image property
► Tap or click the Import button in the Select Resource
dialog box. Use the features of the Open dialog box to
locate the file you want to import into the program
► Select the file you want to import

Chapter 3: Program Design and Coding

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

10



3

Importing the Image
into the Program Resources Folder

►Tap or click the Open button in the Open dialog
box
►Tap or click the OK button in the Select Resource
dialog box

Chapter 3: Program Design and Coding

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

11


3

Sizing an Image

►Select the PictureBox object to resize, and then
scroll in the Properties window until you see the
SizeMode property. Tap or click the SizeMode
property name in the left column, and then tap or
click the SizeMode arrow in the right column of

the SizeMode property
►Tap or click StretchImage in the SizeMode list

Chapter 3: Program Design and Coding

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

12


3

Sizing an Image

Chapter 3: Program Design and Coding

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

13


3

Visible Property

►Select the desired PictureBox object. Scroll in the

Properties window until the Visible property is
displayed. Tap or click the Visible property name
in the left column, and then tap or click the Visible
arrow in the right column of the Visible property
►Tap or click False on the Visible property list

Chapter 3: Program Design and Coding

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

14


3

Visible Property

Chapter 3: Program Design and Coding

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

15


3


Enabled Property

►Select the desired object. Scroll in the Properties
window until the Enabled property is displayed.
Tap or click the Enabled property name in the left
column, and then tap or click the Enabled arrow
in the right column of the Enabled property
►Tap or click False on the Enabled property list

Chapter 3: Program Design and Coding

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

16


3

Enabled Property

Chapter 3: Program Design and Coding

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

17



3

Running a Program

►Point to the Start Debugging button on the
Standard toolbar
►Tap or click the Start Debugging button on the
Standard toolbar

Chapter 3: Program Design and Coding

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

18


3

Entering Visual Basic Code for Event Handling

►With Visual Studio 2015 and the desired program
open and the [Design] tabbed window visible,
point to the desired button object in the Windows
Form object
►Double-tap or double-click the button object

Chapter 3: Program Design and Coding


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

19


3

Entering Visual Basic Code for Event Handling

Chapter 3: Program Design and Coding

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

20


3

Visual Basic 2015 Coding Statements

►The Visual Basic syntax specifies how each
statement must be written
►When the user taps or clicks a button while the
program is running, an action associated with the
coding statement will occur


Chapter 3: Program Design and Coding

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

21


3

General Format of a Visual Basic Statement

Chapter 3: Program Design and Coding

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

22


3

IntelliSense

►IntelliSense displays all allowable entries you
can make in a Visual Basic statement each time a
dot (period), equal sign, or other special character

is required for the statement

Chapter 3: Program Design and Coding

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

23


3

Entering a Visual Basic Statement

► With the code window open and the insertion point
positioned where you want to insert the code, type pic
► To identify the correct entry, type its next letter until the
entry is selected
► When IntelliSense highlights the correct object name,
press the key corresponding to the entry that is to follow
the object name. In this case, press the PERIOD key
► As with the object name in the second step, the next step
is to enter one or more characters until IntelliSense
highlights the desired property in the list. Type the letter v
for the Visible property

Chapter 3: Program Design and Coding

© 2016 Cengage Learning®. May not be scanned, copied

or duplicated, or posted to a publicly accessible website, in
whole or in part.

24


3

Entering a Visual Basic Statement

►Press the key for the character that is to follow
the property name. In this case, press the
SPACEBAR
►Press the EQUAL SIGN key on the keyboard and
then press the SPACEBAR and the letter t
►Type t for True
►Press the key for the character that follows the
True entry. In this case, press the ENTER key

Chapter 3: Program Design and Coding

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

25


×