What is the syntax to split an array based on a value?

Split(expression, delimiter, count, compare)
'expression is a string; only mandatory parameter
'count - how many substrings to be returned. -1 means all substrings are returned
'compare - 0 for binary, 1 for textual

'be aware that the Split function returns an array value, not string value.
‘example – splits the array based on the delimiter “#”
Dim myArray As Variant
Dim size As Integer

myArray = Split("Regular#Regular#Vegetarian#Regular#Vegan", "#")
size = UBound(myArray)

For i = 0 To size
    MsgBox ("Guest " & i & "'s meal option is: " & myArray (i))
Next i

unnamed (2).jpg


What is the syntax to ReDim an array?

Note: ReDims only work for dynamic declarations, not static ones.

Redim <arrayname>(<index>)
Dim badArray(3) As Variant 'static declaration
Dim myArray1() As Variant 'dynamic declaration

ReDim myArray1(3)
myArray1(0) = "z"
myArray1(1) = "zz"
myArray1(2) = "zzz"

ReDim Preserve myArray1(4) 'still keeps previous values in the array
myArray1(3) = "zzzz"
‘array now contains “z,zz,zzz,zzzz”

ReDim myArray1(3) 'erases all previous values in the array
‘array is now empty

What is the syntax to declare an array?

Dim <array name>() ‘array without size
Dim <array name>(<integer>) ‘array with size
Dim <array name>(<integer>) As <data type> ‘declares array with size and data type
Dim myArray(3,4) As Integer ‘a 2D array

Dim myArrayTwo()