User-defined classes in VBScript are instantiated using the
New keyword. Unified Functional Testing has a limitation where you can only instantiate
user-defined classes that are declared in the same script where you are attempting to instantiate it.
A simple trick to overcome this limitation is to declare a
Function that will accompany your
Class, and this function will serve the purpose
of instantiating a new instance of the class and returning that instance to the calling routine.
The following sample code illustrates how you could declare a function to go with your class:
Class MyUserDefinedClass End Class Public Function NewClass_MyUserDefinedClass ' Instantiate and return new instance of the class Set NewClass_MyUserDefinedClass = New MyUserDefinedClass End Function
In the external file that needs to create an instance of this class, you will simply call the function you created instead of trying to instantiate it directly:
Dim myClassInstance Set myClassInstance = NewClass_MyUserDefinedClass