Add new component to test

Private Function AddBPComponent(oTest As Test, _
    oComponent As Component, _
    Optional ContinueOnErr As String = "Continue", _
    Optional NumIterations As Integer = 1, _
    Optional ComponentOrder As Integer = 1) _
    As BPComponent
       
' Create a new BPComponent and add it to a test

' Add the input component to the input test
' and set the properties.
    
    Dim myBPTest As BusinessProcess
    Dim myBPComponent As BPComponent
    
' Cast the test object to a BPTest and add the component.
    Set myBPTest = oTest
    ' Adding the component to the Business Process test
    '  creates the new BPComponent
    Set myBPComponent = myBPTest.AddBPComponent(oComponent)
' Set the properties
    ' Set the execution order of this component instance
    myBPComponent.order = ComponentOrder
    ' Should the parent test fail if this component fails?
    myBPComponent.FailureCondition = ContinueOnErr
    myBPComponent.iterations.Item(1).order = 0
    
'Create the iterations
    Dim i As Integer
    Dim myTempBPParam As BPParameter
    Dim myTempIteration As BPIteration
    For i = 1 To NumIterations - 1
        Set myTempIteration = myBPComponent.AddIteration
        myTempIteration.order = i
        ' Add the parameters to the iteration
        For Each myTempBPParam In myBPComponent.BPParams
            myTempIteration.AddParam myTempBPParam
        Next myTempBPParam
    Next i
    
' Return the BPComponent
    myBPTest.Save
    Set AddBPComponent = myBPComponent
    
End Function