The array functions allow for the manipulation of arrays.
The following functions are available .
Array(): Returns a variant containing an array.
Filter(): Returns a zero-based array that contains a subset of a string array based on a filter criteria.
IsArray(): Returns a Boolean value that indicates whether a specified variable is an array.
Join(): Returns a string that consists of a number of substrings in an array.
LBound(): Returns the smallest subscript for the indicated dimension of an array.
Split(): Returns a zero-based, one-dimensional array that contains a specified number of substring.
UBound(): Returns the largest subscrtpt for the indicated dimension of an array
Array() : The Array() functions returns a variant containing an array.
This function has the form:
Array(arglist):
arglist: A list (separated by commas) of values that is the elements in the array.
Examples: Uses of the array function
a=Array(5,10,15,20)
Msgbox (a(3))
Output: 20
a=Array(5,10,15,20)
For Each x in a
Msgbox (x)
Next
Output:
5
10
15
20
Note: The first element in the array is zero.
Filer(): The Filter() function returns a zero-based array that contains a subset of a string array based on a filter criteria.
This function has the form:
Filter(inputstrings, value[,include [, compare]])
inputstrings: (required) A one-dimensional array of strings to be searched.
value: (rquired) The string to search for
include: (Optional) A Boolean value that indicates whether to return the substrings that inlcude or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as substring (default=True)
compare: (optional) Specifies the string comparision to use. This parameter can have one of the following values:
0=vbBinarCompare- Perform a binary comparison
1=vbTextCompare-Perform a textual comparison.
Example:
Filter items that contains "S"
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
For each x In b
Msgbox(x)
Next
Output: Sunday
Saturday
Items that does NOT contain "S" (include=False)
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
For each x In b
Msgbox(x)
Next
Output:
Monday
Tuesday
Wednesday
Thursday
Friday
Items that contain "S" with a textual comparison (compare=1)
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
For each x In b
Msgbox(x)
Next
Output: Sunday
Tuesday
Wednesday
Thursday
Saturday
Note: If no matches of the value parameter are found, the Filter function will return an empty array.
Note: If the parameter input strings is Null or is NOT a one-dimensional array, an error will occur.
The following functions are available .
Array(): Returns a variant containing an array.
Filter(): Returns a zero-based array that contains a subset of a string array based on a filter criteria.
IsArray(): Returns a Boolean value that indicates whether a specified variable is an array.
Join(): Returns a string that consists of a number of substrings in an array.
LBound(): Returns the smallest subscript for the indicated dimension of an array.
Split(): Returns a zero-based, one-dimensional array that contains a specified number of substring.
UBound(): Returns the largest subscrtpt for the indicated dimension of an array
Array() : The Array() functions returns a variant containing an array.
This function has the form:
Array(arglist):
arglist: A list (separated by commas) of values that is the elements in the array.
Examples: Uses of the array function
a=Array(5,10,15,20)
Msgbox (a(3))
Output: 20
a=Array(5,10,15,20)
For Each x in a
Msgbox (x)
Next
Output:
5
10
15
20
Note: The first element in the array is zero.
Filer(): The Filter() function returns a zero-based array that contains a subset of a string array based on a filter criteria.
This function has the form:
Filter(inputstrings, value[,include [, compare]])
inputstrings: (required) A one-dimensional array of strings to be searched.
value: (rquired) The string to search for
include: (Optional) A Boolean value that indicates whether to return the substrings that inlcude or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as substring (default=True)
compare: (optional) Specifies the string comparision to use. This parameter can have one of the following values:
0=vbBinarCompare- Perform a binary comparison
1=vbTextCompare-Perform a textual comparison.
Example:
Filter items that contains "S"
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
For each x In b
Msgbox(x)
Next
Output: Sunday
Saturday
Items that does NOT contain "S" (include=False)
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
For each x In b
Msgbox(x)
Next
Output:
Monday
Tuesday
Wednesday
Thursday
Friday
Items that contain "S" with a textual comparison (compare=1)
a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
For each x In b
Msgbox(x)
Next
Output: Sunday
Tuesday
Wednesday
Thursday
Saturday
Note: If no matches of the value parameter are found, the Filter function will return an empty array.
Note: If the parameter input strings is Null or is NOT a one-dimensional array, an error will occur.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.