Results 1 to 4 of 4

Thread: Silly question on casting

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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.
    Last edited by venerable bede; Jul 16th, 2009 at 05:59 AM.

    Parksie

  2. #2

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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.

    Parksie

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Silly question on casting

    CType is not a part of VB6...it is a part of VB.NET

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width