First of all you can redimension arrays and maintain the contents using the Presernve command:
Redim Preserve MyArray(x)
However, this is an old, and antiquaited way of doing things that just brings frustraion to a developer You will want to use a collection or a generic list. If you are adding parameters to an SqlCommand, this is not an issue because the Parameters collection is already set for you.
If a = True Then
loCommand.Parameters.Add(MyParm)
End If
If b = True Then
loCommand.Parameters.Add(MyParm)
End If
One class that I use all of the time is a generic List(). This allows you to define a collection of any internal type dynamically.
Dim loParms As New System.Collections.Generic.List(Of AnyClass)
loParms.Add(Class1)
loParms.Add(Class2)
To clear out the list use the Clear command:
loParms.Clear()
You could also create your own collection and collection items by inheriting the CollectionBase class. Bottom line is that you are not going to want to use an array in this situation. You will want to use a collection, list, or dictionary.
Let me know if I need to clear things up.