How declare class in one unit and create class object in other unit...?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2010
10:40 PM
06-17-2010
10:40 PM
How declare class in one unit and create class object in other unit...?
Hi,
I am using TestComplete7, wrritng code in VBScript. an i hav such problem.
I have declare class in unit A - class MyClass
'properties and methods
End Class
And then in unit B i want to create instance of MyClass such way- set myinstance = new MyClass.
In unit B i include unit A .
When the script run, throws exception - "Class not defined: MyClass"
Can't i create object instance in other unit???
I am using TestComplete7, wrritng code in VBScript. an i hav such problem.
I have declare class in unit A - class MyClass
'properties and methods
End Class
And then in unit B i want to create instance of MyClass such way- set myinstance = new MyClass.
In unit B i include unit A .
When the script run, throws exception - "Class not defined: MyClass"
Can't i create object instance in other unit???
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2010
01:59 AM
06-18-2010
01:59 AM
Hi Elya,
In unit A you should create a function that returns an instance of the class and call this function from unit B.
E.g.
' unit A
Function InitClass()
Set InitClass = new MyClass
End Function
class MyClass
'properties and methods
End Class
'unit B
...
Set vClass = Function InitClass()
vClass.Property = ...
intResult = vClass.Function(...)
...
In unit A you should create a function that returns an instance of the class and call this function from unit B.
E.g.
' unit A
Function InitClass()
Set InitClass = new MyClass
End Function
class MyClass
'properties and methods
End Class
'unit B
...
Set vClass = Function InitClass()
vClass.Property = ...
intResult = vClass.Function(...)
...
Regards,
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2010
05:27 PM
06-21-2010
05:27 PM
Ok, thank u.. i understand..
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2010
06:43 PM
06-21-2010
06:43 PM
Oops...
Obviously instead of
'unit B
...
Set vClass = Function InitClass()
it had to be
'unit B
...
Set vClass = InitClass() ' copy-pasted 'Function' is not needed here
Sorry for the typo...
Obviously instead of
'unit B
...
Set vClass = Function InitClass()
it had to be
'unit B
...
Set vClass = InitClass() ' copy-pasted 'Function' is not needed here
Sorry for the typo...
Regards,
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
