Test Design StudioGo to Previous Topic: CA0111 - Cannot instantiate external classesGo to Next Topic: CA0113 - Do not assign values to constants

CA0112 - Invalid assignment statement


VBScript requires you to use the Set keyword when assigning object-based references to variables, and the Set keyword must not be used when working with scalar or non-object-based references.


If you are assigning an object-based reference to a variable, make sure you use the Set keyword.

[VBScript] - Copy Code
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

If you are assigning non-object-based data to a variable, do not use the Set keyword.

[VBScript] - Copy Code
Dim fileName
fileName = "C:\MyFolder\MyFile.txt"

If you have a mixed-use variable that is sometimes used to reference object-based data and other times used to reference non-object-based data, Test Design Studio my require you to explicitly declare the variable as a Variant type. All variables, by default, hold Variant data, but some of the auto-detection techniques used by Test Design Studio to infer to type of a variable may result in Test Design Studio thinking the variable is used for object-based data only. To force the variable to be treated as a Variant, you must use XML comments to explicitly define the type of the variable as shown in the mixed-use code below:

[VBScript] - Copy Code
''' <value type="Variant"/>
Dim myVar
Set myVar = CreateObject("Scripting.FileSystemObject")
myVar = "C:\MyFolder\MyFile.txt"