TAILIEUCHUNG - Mastering Microsoft Visual Basic 2008 phần 2

Chú ý này có thể được mở rộng đến hơn hai chiều. Các báo cáo sau đây tạo ra một mảng với yếu tố (10 10 10): Bạn có thể nghĩ về một mảng ba chiều như một khối lập phương của chồng mảng hai chiều, chẳng hạn như một hiển thị trong hình . | 80 chapter 2 VARIABLES AND DATA TYPES This notation can be extended to more than two dimensions. The following statement creates an array with 1 000 elements 10 by 10 by 10 Dim Matrix 9 9 9 You can think of a three-dimensional array as a cube made up of overlaid two-dimensional arrays such as the one shown in Figure . FIGURE Pictorial representations of one- two- and three-dimensional arrays Data 7 3 Data 7 3 3 It is possible to initialize a multidimensional array with a single statement just as you do with a one-dimensional array. You must insert enough commas in the parentheses following the array name to indicate the array s rank. The following statements initialize a two-dimensional array and then print a couple of its elements Dim a As Integer 10 20 a 0 1 a 2 2 30 11 21 31 12 22 32 will print 20 will print 32 You should break the line that initializes the dimensions of the array into multiple lines to make your code easier to read. Just insert the line continuation character at the end of each continued line Dim a As Integer 10 20 30 11 21 31 12 22 32 If the array has more than one dimension you can find out the number of dimensions with the property. Let s say you have declared an array for storing names and salaries by using the following statements Dim Employees 1 99 As Employee To find out the number of dimensions use the following statement ARRAYS 81 When using the Length property to find out the number of elements in a multidimensional array you will get back the total number of elements in the array 2 X 100 for our example . To find out the number of elements in a specific dimension use the GetLength method passing as an argument a specific dimension. The following expressions will return the number of elements in the two dimensions of the array 0 2 1 100 Because the index of the first array element is zero the .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.