Unimatrix_001
asked on
Error: Expression is not a method
Hi,
From the below code, the problem I'm having is on the second last line starting with DirectCast - I'm placing an object into CObjectManager and attempting to get it back casting it to a CTest class but the error I'm getting is:
"Expression is not a method."
I would appreciate some insight.
Thanks,
Uni
From the below code, the problem I'm having is on the second last line starting with DirectCast - I'm placing an object into CObjectManager and attempting to get it back casting it to a CTest class but the error I'm getting is:
"Expression is not a method."
I would appreciate some insight.
Thanks,
Uni
Public Interface IObject
End Interface
Public Class CTest
implements IObject
//Misc methods.
End Class
Public Module CObjectManager
Private activeObject As IObject
//set and get methods for activeObject
End Module
Public Sub Main()
Dim testObject as New CTest
CObjectManager.setActiveObject(testObject)
DirectCast(CObjectManager.getActiveObject(), CTest).CTestMethods()
End Sub
Is CTestMethods your data type you want the data to be mapped into.
if it is then you need
CTestMethods = DirectCast(CObjectManager. getActiveO bject(), CTest)
if it is then you need
CTestMethods = DirectCast(CObjectManager.
ASKER
Hi there,
Hm, I am not understanding this very well. See, my class is CTest that's what I'm wanting to typecast into. So I could do something such as:
CTest returnedValue=CObjectManag er.getActi veObject()
But clearly I cannot do that (can I???) because getActiveObject returns an IObject, which needs to be cast.
Thank you,
Uni
Hm, I am not understanding this very well. See, my class is CTest that's what I'm wanting to typecast into. So I could do something such as:
CTest returnedValue=CObjectManag
But clearly I cannot do that (can I???) because getActiveObject returns an IObject, which needs to be cast.
Thank you,
Uni
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh I read your code now
you want it in variable testObject right?
testObject = DirectCast(CObjectManager. getActiveO bject(), CTest)
you want it in variable testObject right?
testObject = DirectCast(CObjectManager.
ASKER
That's lovely - thank you. :)
DirectCast(CObjectManager.
is what you do to run a METHOD i.e.... Screen().ClearScreen() would be a method to clear the screen (A Method does something)
you need to format an expression for example
SOMETHING = DirectCast(CObjectManager.
hope this helps