Provide a Name and Description for the task by typing them in the editor.
The Name is, "Calculate Using Variables". The Description is, "Get variables,
calculate and Display result".
4. Right-click on an empty area in the Control Flow page of the 'Canvas' and
from the pop-menu choose Variables.
This brings up the Variables window that is empty to start with. Use the
Add Variable icon twice to add two variables a, and b, of type Int32. You can
also specify what value they should have. This has been described in detail in
an earlier chapter.
5. In the half-finished window, type over Variable1 with b.
The variables a, and b are now defined in the Scope of the "scripts" and available
for the scripts.
6. Change the PrecompileScriptIntoBinaryCode line item to false in the Script
list item of the Script Task Editor, and click on the Design Script??¦ button.
Chapter 19
[ 279 ]
7. Add the two variables as shown in the next screenshot to the Script Task
Editor in the line item, ReadOnlyVariables.
8. Click on the button Design Script??¦ to open the Microsoft Visual Studio
for Applications window and type in the following code at the indicated
location.
Public Sub Main()
'
' Add your code here
Dim x As Variable
x = Dts.Variables(0)
Dim y As Variable
y = Dts.Variables(1)
Dim c As Integer
MsgBox(CInt(x.Value) * CInt(y.Value))
Dts.TaskResult = Dts.Results.Success
End Sub
It is easy to see that x is referencing the variable a given by Dts.
Pages:
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196