microsoft visual basic 2015 chapter 07

43 90 0
 microsoft  visual basic 2015 chapter 07

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Microsoft Visual Basic 2015 CHAPTER SEVEN Using Procedures and Exception Handling Objectives ►Create a splash screen ►Pause the splash screen ►Add a ComboBox object to a Windows Form ►Write Code for a SelectedIndexChanged event ►Understand procedures ►Code a Sub procedure Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Objectives ►Pass an argument to a procedure by value ►Pass an argument to a procedure by reference ►Code a Function procedure to return a value ►Create a class-level variable ►Catch an exception using a Try-Catch block ►Determine the order of exceptions in a Try-Catch block Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Introduction ►As an application grows, it is important to divide each facet of a problem into separate sections of code called procedures ►Try-Catch blocks can check for any error a user might commit ►One way to make your programs more professional is to display a splash screen while the full program loads Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Creating a Splash Screen ► Create a Windows Desktop application named Mystery Escape Name the form frmEscape Tap or click Project on the menu bar and then tap or click Add New Item on the Project menu Scroll down to view Splash Screen ► In the Add New Item dialog box, select Splash Screen in the center pane ► Tap or click the Add button in the Add New Item dialog box ► Tap or click the left side of the splash screen form to select it To set the application to display the splash screen first, press and hold or right-click Mystery Escape in the Solution Explorer ► Tap or click Properties on the shortcut menu Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Creating a Splash Screen ►In the Windows application framework properties section, tap or click the Splash screen list arrow, and then tap or click SplashScreen1 to select it as the splash screen used for the project ►Tap or click the Assembly Information Button on the Project Designer to open the Assembly Information dialog box ►To customize the splash screen, change the copyright to the present year The numbers in the File version boxes can be changed as you update the application Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Creating a Splash Screen ► Tap or click the OK button on the Assembly Information dialog box Close the Mystery Escape* Project Designer window To change the predefined image, first make sure you have the Escape.jpg picture (available on CengageBrain.com) and that you stored the image in a location you remember Then, tap or click the SplashScreen1.vb [Design] tab Tap or click the left side of the splash screen, making sure to select the entire splash screen form The Properties window should identify MainLayoutPanel if you have selected the entire splash screen form Tap or click to the right of the BackgroundImage property in the Properties window, and then tap or click the ellipsis button In the Select Resource dialog box, tap or click the Project resource file radio button, if necessary Import the Escape.jpg picture by tapping or clicking the Import button in the Select Resource dialog box and selecting the Escape jpg image from the location where you stored it Tap or click the OK button in the Select Resource dialog box ► Run the application by tapping or clicking the Start Debugging button on the Standard toolbar â 2016 Cengage Learningđ May not be scanned, copied or Chapter 7: Using Procedures and Exception Handling duplicated, or posted to a publicly accessible website, in whole or in part 7 Creating a Splash Screen Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Pausing the Splash Screen ► After the splash screen loads, the application executes any code in the form load event handler To display the splash screen for five seconds, you insert code that calls the Sleep procedure in the form load event handler To open the code window and the form load event handler, double-tap or double-click the background of the frmEscape Windows Form object in the Design window ► Tap or click inside the frmEscape_Load event handler Type Threading to have IntelliSense display a list of possible entries If necessary, type T to select Thread from the IntelliSense list Type S to select Sleep from the IntelliSense list Type (5000) Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Pausing the Splash Screen Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 10 Exception Handling ►The Try-Catch set of statements detects exceptions and takes corrective action Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 29 Exception Handling Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 30 Exception Handling Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 31 Exception Handling Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 32 Program Design Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 33 Program Design Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 34 Program Design Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 35 Program Design when Using Sub and Function Procedures ►Larger programs often should be divided into procedures that perform specific tasks within the program • Makes the program easier to read, understand, and debug ►The developer must determine what code should be placed in a procedure Procedures should: • Perform a single, defined task • Perform reasonably substantial processing ►Use Sub and Function procedures appropriately Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 36 Event Planning Document Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 37 Event Planning Document Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 38 Event Planning Document Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 39 Event Planning Document Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 40 Summary ►Create a splash screen ►Pause the splash screen ►Add a ComboBox object to a Windows Form ►Write Code for a SelectedIndexChanged event ►Understand procedures ►Code a Sub procedure Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 41 Summary ►Pass an argument to a procedure by value ►Pass an argument to a procedure by reference ►Code a Function procedure to return a value ►Create a class-level variable ►Catch an exception using a Try-Catch block ►Determine the order of exceptions in a Try-Catch block Chapter 7: Using Procedures and Exception Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 42 Microsoft Visual Basic 2015 CHAPTER SEVEN COMPLETE Using Procedures and Exception Handling ... scanned, copied or Chapter 7: Using Procedures and Exception Handling duplicated, or posted to a publicly accessible website, in whole or in part 7 Creating a Splash Screen Chapter 7: Using Procedures... task but does not return any data to the calling procedure ► A Sub procedure is the series of Visual Basic statements enclosed by the Sub and End Sub statements ► A Sub procedure is called with... make your programs more professional is to display a splash screen while the full program loads Chapter 7: Using Procedures and Exception Handling © 2016 Cengage Learning® May not be scanned,

Ngày đăng: 06/02/2018, 10:06

Mục lục

  • Slide 1

  • Objectives

  • Objectives

  • Introduction

  • Creating a Splash Screen

  • Creating a Splash Screen

  • Creating a Splash Screen

  • Creating a Splash Screen

  • Pausing the Splash Screen

  • Pausing the Splash Screen

  • Adding a ComboBox Object

  • Adding a ComboBox Object

  • Adding a ComboBox Object

  • Determining the ComboBox Selected Index

  • Handling SelectedIndexChanged Events

  • Procedures

  • Coding a Sub Procedure

  • Coding a Sub Procedure

  • Passing Arguments

  • Passing Arguments by Value (ByVal)

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan