Creating an object via Function Library - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Creating an object via Function Library (/Thread-Creating-an-object-via-Function-Library) |
Creating an object via Function Library - riechan - 06-19-2012 Hi, Is it possible to create a description of an object via a function from the function library? I'm trying to get this code to work properly, but I keep getting the error: "Wrong number of arguments or invalid property assignment." The description of the objTextbox is created when I call the function, but it returns back to the action as Empty. Can anyone help? This is the code from the action, Flight_NewSale: Code: Public objTextbox And then here's the code from the Function Library: Code: Public Function createTextbox(nameProperty, valProperty) RE: Creating an object via Function Library - vibhakhandelwal - 06-19-2012 Hi, You can create an objects description by using Description object. example is given below Code: Dim oDesc 'Description Object 'We used Desktop as the parent here because, the Desktop Object holds all the Windows Code: Set colObject = Desktop.ChildObjects( oDesc ) RE: Creating an object via Function Library - sshukla12 - 06-19-2012 Hi, Please find the below code 4 refrence: Code: Set vo_ResDesc=createDescription("Link",DataTable("REScreateexport",dtGlobalSheet)) Let me know in case of any help required. Regards, Sankalp RE: Creating an object via Function Library - riechan - 06-20-2012 Thanks, I tried using your code as reference, like so: Code from action, Flight_NewSale: Code: Public txtName Code from function library, createObject: Code: Public objInst But I get this error: ActiveX component can't create object: 'WinEdit': Code: Set txtName = createObject("WinEdit", "Arrival Time:") When I check the values of the objects in watch, it says there that both txtName and objInst are empty. Since I'm really new to QTP, may I just confirm, are the codes you posted above both located in the function library (or both located in the action script), or are they from different locations (the line: Code: Set vo_ResDesc=createDescription("Link",DataTable("REScreateexport",dtGlobalSheet)) is found only in the action script and the function createDescription is located at the function library)? in the action script, and the rest of the function createDescription in the Thanks, tip about the micclass has been noted. However, I do know how to create descriptions of objects. What I want to know is, if I can create the descriptions of the objects using a function from the function library. RE: Creating an object via Function Library - riechan - 06-22-2012 Solved it. Again, thanks sshukla12! Code: Public frmFlightReservation Code: Public Function createDescription(typeObject, valProperty, auxProperty, auxPropertyVal) RE: Creating an object via Function Library - sshukla12 - 06-22-2012 U r always welcome. Regards, Sankalp |