Silly question on casting
Hi All
VB 6.0
I am a c# developer usually but have had to create a vb 6 application to test a COM object.
The problem I have is that I get the following error when I run the code below :
Sub or Function not define
Code:
Dim objClass As New clsAPI
Dim objInterface As IAPI
objInterface = CType(objClass, IAPI)
It can't find CType. I don't get it. Is Ctype in some surreal location?
I suppose VB 6 can't do this at all.
Re: Silly question on casting
It doesn't matter.
I take it VB 6 just cannot do this.
I'll have to change my COM callable .net code and remove the interface.
Re: Silly question on casting
Have you tried: Set objInterface = objClass.
For example, the stdPicture class implements IPicture and IPictureDisp. Therefore, I can do this:
Code:
Dim newPic As New stdPicture
Dim IPic As IPicture, IPICD as IPictureDisp, IUNK As IUnknown
Set IPIC = newPic
Set IPICD = newPic
Set IUNK = newPic ' and of course it also implements IUnknown
Re: Silly question on casting
CType is not a part of VB6...it is a part of VB.NET