To Define arrays for storing lists of data (up to 10 sets)…
Option Explicit
Private Const MAX = 10
Private Names(1 To MAX) As String
The code shown above should be added to the DataManagement module. Note that the keywords Option Explicit may already be there, depending on how Visual Basic is set up. Add them if not. Note that, in addition to the actual array declaration for the Names array, a Constant has been declared (a fixed value that we give a name to). The constant is used wherever we wish to refer to the size of the array or the position of the last element, the advantage of this being that if we wanted to change to an array of 100 entries, we could simply change the value of the constant.
Ö Create the data declarations as shown above.
Ö Add a second array declaration (immediately below the Names array declaration) for
storing up to MAX Marks. The elements of this array must be capable of storing integer
numbers suitable for representing a mark.
Part of the job of managing this list of information will be to keep track of how full the array is. Using a numeric variable to indicate the location (in the range 1 to MAX) of the most recent entry will tell us where to put the next entry, and when we have no more space to use.
Ö Add a suitable declaration for a LastEntry variable below the declaration of the Marks
array, choosing a data type that will accommodate the required range of LastEntry.
Option Explicit
Private Const MAX = 10
Private Names(1 To MAX) As String
The code shown above should be added to the DataManagement module. Note that the keywords Option Explicit may already be there, depending on how Visual Basic is set up. Add them if not. Note that, in addition to the actual array declaration for the Names array, a Constant has been declared (a fixed value that we give a name to). The constant is used wherever we wish to refer to the size of the array or the position of the last element, the advantage of this being that if we wanted to change to an array of 100 entries, we could simply change the value of the constant.
Ö Create the data declarations as shown above.
Ö Add a second array declaration (immediately below the Names array declaration) for
storing up to MAX Marks. The elements of this array must be capable of storing integer
numbers suitable for representing a mark.
Part of the job of managing this list of information will be to keep track of how full the array is. Using a numeric variable to indicate the location (in the range 1 to MAX) of the most recent entry will tell us where to put the next entry, and when we have no more space to use.
Ö Add a suitable declaration for a LastEntry variable below the declaration of the Marks
array, choosing a data type that will accommodate the required range of LastEntry.
文章標籤
全站熱搜

明顯是作業。