Your SlideShare is downloading. ×
0
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
MELJUN CORTES ARRAY
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MELJUN CORTES ARRAY

91

Published on

MELJUN CORTES ARRAY

MELJUN CORTES ARRAY

Published in: Technology, Spiritual
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
91
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • When you create an array, Visual Basic sets aside room for it in memory. The following screen shot shows conceptually how the 10-element Employees array is organized.
  • When you create an array, Visual Basic sets aside room for it in memory. The following screen shot shows conceptually how the 10-element Employees array is organized.
  • Transcript

    • 1. MELJUN CORTESMELJUN CORTES
    • 2.  A simple or scalar variable is one that is unrelated to any other variable in memory  An array is a group of variables that have the same name and data type and are related in some way  The most commonly used arrays are one- dimensional and two-dimensional  Programmers use arrays to store related data in the internal memory of the computer
    • 3.  If you declare an array locally in a procedure, you can use it only in that procedure.  If you declare an array at the top of a form, you can use it throughout the form.  If you declare an array publicly in a module, you can use it anywhere in the project.
    • 4. Syntax Elements in Array Declaration Description Array name The name you’ll use to represent your array in the program. In general, array names follow the same rules as variable names. Data type The type of data you’ll store in the array. In most cases, all the variables in an array are the same type. Number of dimensions The number of dimensions that your array will contain. Most arrays are one-dimensional (a list of values) or two-dimensional (a table of values), but you can specify additional dimensions Number of elements The number of elements that your array will contain. The elements in your array correspond directly to the array index. The first array index is always 0 (zero).
    • 5.  For example, to declare a one-dimensional string array named Employees that has room for 10 employee names (numbered 0 through 9), you can type the following in an event procedure: Dim Employees(9) As String Public Employees(9) As String Dim Employees(0 To 9) As String
    • 6.  To declare a public two-dimensional array named Scoreboard that has room for two rows and nine columns of Short integer data, you can type this statement in an event procedure or at the top of the form:: Dim Scoreboard(1, 8) As Short Dim Scoreboard(0 To 1, 0 To 8) As Short
    • 7.  To refer to an element of an array, you use the array name and an array index enclosed in parentheses. Employees(5) = "Leslie"
    • 8.  To refer to an element of an array, you use the array name and an array index enclosed in parentheses. Scoreboard(0, 2) = 4
    • 9.  To create an array in this manner, you use what is called an array literal  An array literal consists of a list of comma- separated values that are enclosed in braces ({}).
    • 10.  A subscript must reference a valid element of the array. lf a list contains 10 names it wouldn't make sense to ask: What is the 15th name on the list? Or What is the 21/2th name on the list? Visual Basic rounds fractional subscripts and throws an exception for a subscript that is out of range.  Each individual variable is called an element of the array.  Note: Arrays are based on System.Array, which is a collection.
    • 11.  Fixed Array program uses the UBound function to check for the upper bound, or top index value, of the array. LBound(ArrayName) UBound(ArrayName) •LBound function, which confirms the lower index value, or lower bound, of
    • 12.  LBound function, which confirms the lower index value, or lower bound, of an array, is
    • 13.  Dynamic arrays are dimensioned at run time, either when the user specifies the size of the array or when logic you add to the program determines an array size based on specific
    • 14.  ReDim statement specifies the size of a dynamic array at run time  If you redimension an array that already has data in it, all the existing data is irretrievably lost Dim Temperatures() As Single Dim Days As Short Days = InputBox("How many days?", "Create Array" ReDim Temperatures(Days - 1)
    • 15.  Allows you to preserve the data in an array when you change its dimensions. Dim Philosophers() As String you can redimension the array and add data to it by using code similar to the following: ReDim Philosophers(200) Philosophers(200) = "David Probst" You can expand the size of the Philosophers array to 301 elements (0–300), and preserve the existing contents, by using the following syntax: ReDim Preserve Philosophers(300)
    • 16.  To use an array to store items that are related but have different data types.  One solution is to use two parallel one- dimensional arrays: a String array to store the IDs and an Integer array to store the salaries.  Parallel arrays are two or more arrays whose elements are related by their position in the arrays.

    ×