microsoft visual basic 2015 chapter 08

43 116 0
 microsoft  visual basic 2015 chapter 08

Đ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 EIGHT Using Arrays and File Handling Objectives ►Initialize an array ►Initialize an array with default values ►Access array elements using a loop ►Use ReDim to resize an array ►Determine the number of elements in an array using the Length command ►Use the For Each loop Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Objectives ►Initialize two-dimensional arrays ►Read a text file ►Write to a text file ►Calculate depreciation ►Use multiple Form objects ►Access variable objects on other forms Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Introduction Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Introduction to Arrays ►An array variable is simply a variable that can store more than one value ►Each individual item in array that contains a value is called an element ►Arrays provide access to data by using a numeric index, or subscript, to identify each element in the array Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Initializing an Array ►To declare an array in a program, you must include an array declaration statement, which states the name of the array, how many items it can store, and what sort of data it can store Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Initializing an Array ►Parallel arrays store related data in two or more arrays Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Accessing Array Elements Using a Loop Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 8 Array Boundaries ► The Visual Basic compiler determines if each subscript is within the boundaries set when you initialized the array ► An array can use a constant value representing its upper-bound index ► Every array in Visual Basic is considered dynamic, which means that you can resize it at run time ► The ReDim statement assigns a new array size to the specified array variable • All data in the array will be lost ► If you want to preserve the existing data you can use the keyword Preserve • Ex: ReDim Preserve Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part Using the Length Property ►The Length property of an array contains the number of elements in an array Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 10 Computing Depreciation ►Depreciation is the decrease in property value and the reduction in the balance sheet value of a company asset to reflect its age and prolonged use ►The simplest and most common method, straight-line depreciation, is calculated by dividing the purchase or acquisition price of an asset by the total productive years it can reasonably be expected to benefit the company, which is called the life of the asset Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 29 Computing Depreciation ►The double-declining balance depreciation method is like the straight-line method doubled Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 30 Using Multiple Form Objects ► Tap or click Project on the menu bar, and then tap or click Add Windows Form ► In the Add New Item dialog box, tap or click Windows Form, and then type frmDisplayInventory.vb in the Name text box ► Click the Add button in the Add New Item dialog box A second Form object named frmDisplayInventory.vb opens in the Visual Basic 2015 window In the Properties window, change the Text property of the frmDisplayInventory object to Sorted Inventory Listing Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 31 Using Multiple Form Objects Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 32 Startup Objects ►Every application begins executing a project by displaying the object designated as the Startup object Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 33 Creating an Instance of a Windows Form Object ► To display a second or subsequent form, the initial step is to create an instance of the Windows Form object ► When creating multiple Windows Form objects, Visual Basic allows you to generate two types of forms: modal and modeless • • A modal form retains the input focus while open A modeless form allows you to switch the input focus to another window Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 34 Accessing Variables on Other Forms ►You control the availability of a variable by specifying its access level, or access specifier Chapter 8: Using Arrays and File 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 Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 36 Program Design Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 37 Designing the Program Processing Objects Chapter 8: Using Arrays and File Handling © 2016 Cengage Learning® May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 38 Designing the Program Processing Objects Chapter 8: Using Arrays and File Handling â 2016 Cengage Learningđ May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part 39 Designing the Program Processing Objects Chapter 8: Using Arrays and File 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 ►Initialize an array ►Initialize an array with default values ►Access array elements using a loop ►Use ReDim to resize an array ►Determine the number of elements in an array using the Length command ►Use the For Each loop Chapter 8: Using Arrays and File 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 ►Initialize two-dimensional arrays ►Read a text file ►Write to a text file ►Calculate depreciation ►Use multiple Form objects ►Access variable objects on other forms Chapter 8: Using Arrays and File 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 EIGHT COMPLETE Using Arrays and File Handling ... frmDisplayInventory.vb opens in the Visual Basic 2015 window In the Properties window, change the Text property of the frmDisplayInventory object to Sorted Inventory Listing Chapter 8: Using Arrays and... duplicated, or posted to a publicly accessible website, in whole or in part 8 Array Boundaries ► The Visual Basic compiler determines if each subscript is within the boundaries set when you initialized... array ► An array can use a constant value representing its upper-bound index ► Every array in Visual Basic is considered dynamic, which means that you can resize it at run time ► The ReDim statement

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

Mục lục

  • Slide 1

  • Objectives

  • Objectives

  • Introduction

  • Introduction to Arrays

  • Initializing an Array

  • Initializing an Array

  • Accessing Array Elements Using a Loop

  • Array Boundaries

  • Using the Length Property

  • Using Arrays

  • The For Each Loop

  • The For Each Loop

  • Scope of Arrays

  • Passing an Array

  • Sorting an Array

  • Searching an Array

  • Creating a Two-Dimensional Array

  • Creating a Two-Dimensional Array

  • File Handling

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

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

Tài liệu liên quan