Copy Code
|
|
---|---|
Private Sub AddParamAndStep(ByRef myComponent) ' Add a parameter and step to a component Dim compParamFactory As ComponentParamFactory Dim compParam1 As ComponentParam Dim compStepFactory As ComponentStepFactory Dim compStep1 As ComponentStep ' This example adds a parameter and step to the Component. Set compParamFactory = myComponent.ComponentParamFactory Set compStepFactory = myComponent.ComponentStepFactory ' Create a parameter and set the properties. Set compParam1 = compParamFactory.AddItem(Null) ' Output parameter. For ComponentParam.IsOut, 1 true and 0 is false compParam1.IsOut = 1 compParam1.name = "OutParam" compParam1.desc = "Description for output parameter" compParam1.ValueType = "String" compParam1.order = 1 compParam1.Post ' Create a step Set compStep1 = compStepFactory.AddItem(Null) compStep1.StepName = "First Step" ' Add description and expected results that contain parameters. Dim pString As String 'Input parameter. For this example, assume that InParam was previously created. ' pString ="Description can contain <<<InParam>>> that are verified by QC" pString = "<html><body>Description can contain " _ & "<<<InParam>>>" _ & "that are verified by QC</body></html>" compStep1.StepDescription = pString 'Output parameter. OutParam was previously created. badParamName was not. ' pString ="Can also contain <<<OutParam>>> and <<<badParamName>>>" 'Given that badParamName is not the name of any parameter, ' <<<badParamName>>> will be replaced by <badParamName>, so that ' the user can see in the user interface that it is not recognized. pString = "<html><body>Can also contain " _ & "<<<OutParam>>>" _ & "and <<<badParamName>>>" _ & " </body></html>" compStep1.StepExpectedResult = pString 'Set the execution order compStep1.order = 1 'Finish the step 'Validate will throw an exception because of the badParamName. ' In real production code, you may wish to catch the exception ' and take action rather than continuing as this example does. 'On Error GoTo myInvalidStepHandler On Error Resume Next compStep1.Validate compStep1.Post ' Save changes and unlock the component. myComponent.Post End Sub |