Del

The Delete function deletes a field, subfield, or sub-subfield from a dynamic array.

Group: Dynamic Array Extensions


Syntax: vREC = Del(vREC, vFLD, [vSUB], [vSSUB])

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

sNames = "John&Mike&Albert"  ' Three records of names

sNames = Del(sNames, 3)      'sNames becomes "John&Mike"

sNames = "John&Mike&Albert"  ' Three records of names

sNames = Del(sNames, 2)      'sNames becomes "John&Albert"

This next example shows each record with 3 values; Name, Age and Language.

sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"

sNames = Del(sNames, 1)

   'sNames becomes "Mike#34#Spanish&Albert#40#English"

sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"

sNames = Del(sNames, 2)  

   'sNames becomes "John#31#English&Albert#40#English"

You can also delete portions of a record.

sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"

sNames = Del(sNames, 2, 1)  

 'sNames becomes "John#31#English&34#Spanish&Albert#40#English"

sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"

sNames = Del(sNames, 2, 2)  

'sNames is now "John#31#English&Mike#Spanish&Albert#40#English"

sNames = "John#31#English&Mike#34#Spanish&Albert#40#English"

sNames = Del(sNames, 2, 3)  

   'sNames becomes "John#31#English&Mike#34&Albert#40#English"

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...

sNames = Del(sNames, 1, 3, 1)

   'sNames becomes "John#31# UnitedKingdom English&Mike...

Here everything between the Chr(1) delimiters is considered the first field. The 2 versions of English are a part of the third sub-field. So reading the DEL statement: “Using the first field, look at the third sub-field (all the languages) and delete the first sub-subfield.

A Dynamic Array is like a database stored as a single string. Everything between the Chr(1) delimiters are fields referenced by the first number. If there are any Chr(2) delimiters, each piece makes up the complete record. If there are any Chr(3) delimiters, they make up the complete subfield.