Micro Focus QTP (UFT) Forums
Concept of Init Function of class - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Concept of Init Function of class (/Thread-Concept-of-Init-Function-of-class)



Concept of Init Function of class - Star - 07-31-2009

Hi,

I m creating a class named TestReportFile, in which i want to create Excel file. I want that on creation of object of TestReportFile class, Excel test report file should be created.
Like this:

Set obj = new TestReportFile ' This should create Excel file in required directory. And in Init() of TestReportFile class, i wrote code for creation of Excel report file. Because i assume that on creation of object Init() is called of that class. But this did not happen.

Please tell me how Init() will be called? and on creation of object of a class, does Init() is called or not? What is the usage of Init() in classes? What is the concept of constructor of a class in QTP?

Thanks


RE: Concept of Init Function of class - Saket - 07-31-2009

create an object of your class. say - Set oClass = New TestReportFile
Now you can initialise this with
oClass.Init()

In QTP you will need to cal the init function. it will not get aumatically at the time of creting object.