Ext
The Extract function returns a field, subfield, or sub-subfield value from a dynamic array.
Group: Dynamic Array Extensions
Syntax: vVAL = Ext(vREC, vFLD, [vSUB], [vSSUB])
vVAL (Variant) is the string value extracted from the array.
vREC (Variant) is the dynamic array variable name
vFLD (Variant) is the array field number to search
vSUB (Variant) Optional – is the array subfield number
vSSUB (Variant) Optional – is the array sub-subfield number
Example:
Dim sNames As String
Dim sValue As String
sNames = "John&Mike&Albert" ' Three records of names
sValue = Ext(sNames, 2) 'sValue becomes "Mike"
sNames = "John&Mike&Albert" ' Three records of names
sValue = Ext(sNames, 3) 'sValue becomes "Albert"
This next example shows each record with 3 values; Name, Age and Language.
sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"
sValue = Ext(sNames, 2, 3) 'sValue becomes "Spanish"
Here Mike#34#Spanish is the second record and the third subfield value was retrieved.
Using the Sub-subfield concept, maybe the language has sub categories like Canadian English and United Kingdom English.
sNames = "John#31#Canadian English@UnitedKingdom English&Mike...
sValue = Ext(sNames, 1, 3, 1) 'sValue becomes "Canadian English"
There are times when the Extract function can be very helpful. For example, if you create a comma-delimited list of items and must parse through it, writing code to manipulate the string and keep track of the pointer can be extensive. Instead use a statement like:
sList = Replace(sList, ",", Chr(1))
This replaces the comma with the Chr(1) character. Then in the loop you only need to EXT(sList, i) to get each entry out. Use the DCount command to get the length of the list.