Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting error "Object doesn't support while accessing a function - QTP

Status
Not open for further replies.

Karthikeyan082075

Programmer
May 22, 2006
4
US
I have 2 classes. i have a constant that decides on module that i am going to work. Based on the constant value, either of the 2 classes gets instiantiated. then i am trying to use the functions that i defined inside these classes. But when i try accessing the function, i am getting error message
"Object doesn't support this property or method: airSearch.find'
line (70) "airSearch.find()"

Can any one tell me what is the wrong in my code?

Code Snippet:
---------------------------------------------------------
MODULE = "A"
MODULE = "B"

Class MODULEAirSearchFactory

Private Sub Class_Initialize

MsgBox "air search"

End Sub

Function getAirSearch ()

If MODULE = "A" Then
Set getAirSearch = New AAirSearch
End If

If MODULE = "B" Then
Set getAirSearch = New BAirSearch
End If

End Function

Private Sub Class_Terminate
'MsgBox Name & ": Goodbye, world!"
End Sub

End Class


Class AAirSearch

Private Sub Class_Initialize
MsgBox "hi"
End Sub

Public Function find ( )
MsgBox ("A air search being performed")
End Function

Private Sub Class_Terminate
'MsgBox Name & ": Goodbye, world!"
End Sub

End Class


Class BAirSearch

Private Sub Class_Initialize
MsgBox "hi"
End Sub

Public Function find ( )
MsgBox ("B air search being performed")
End Function


Private Sub Class_Terminate
'MsgBox Name & ": Goodbye, world!"
End Sub

End Class

'#########################################################

Set airSearch = New MODULEAirSearchFactory
airSearch.getAirSearch()
airSearch.find()

Thanks.

 
The find method is not defined as a function of the MODULEAirSearchFactory class. Therefore objects cannot use the method.

Your find method is created under AAirSearch and BAirSearch. You create airSearch as an instance of MODULEAirSearchFactory.



Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top