Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. receiving a Boolean type in VB

receiving a Boolean type in VB

Scheduled Pinned Locked Moved COM
c++helpcomquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jerome Conus
    wrote on last edited by
    #1

    Hi ! I'm still beginning with COM ! I'd like to do a very simple ATL component with Visual C++. The interface of this component would implement only one method, which would return a boolean value. This value would be read from a Visual Basic app. The problem is when I use the 'boolean' type for my interface, VB doesn't recognize it. I tried to use the 'short' type, but VB recognize it as an Integer. What type should I use in my ATL interface so that VB receives a 'Boolean' type ? Thank you for your help, Jerome

    P A 2 Replies Last reply
    0
    • J Jerome Conus

      Hi ! I'm still beginning with COM ! I'd like to do a very simple ATL component with Visual C++. The interface of this component would implement only one method, which would return a boolean value. This value would be read from a Visual Basic app. The problem is when I use the 'boolean' type for my interface, VB doesn't recognize it. I tried to use the 'short' type, but VB recognize it as an Integer. What type should I use in my ATL interface so that VB receives a 'Boolean' type ? Thank you for your help, Jerome

      P Offline
      P Offline
      pba_
      wrote on last edited by
      #2

      Pass a VARIANT structure with VT_BOOL type. For example : HRESULT Object::Test( /*[out,retval]*/VARIANT* pOut) { *pOut = NULL; CComVariant vRet( true); vRet.Detach( pOut); return S_OK; }

      1 Reply Last reply
      0
      • J Jerome Conus

        Hi ! I'm still beginning with COM ! I'd like to do a very simple ATL component with Visual C++. The interface of this component would implement only one method, which would return a boolean value. This value would be read from a Visual Basic app. The problem is when I use the 'boolean' type for my interface, VB doesn't recognize it. I tried to use the 'short' type, but VB recognize it as an Integer. What type should I use in my ATL interface so that VB receives a 'Boolean' type ? Thank you for your help, Jerome

        A Offline
        A Offline
        Anand Amirineni
        wrote on last edited by
        #3

        Just more Info for you. In C++, TRUE is +1, but VB and automation clients use TRUE as -1 and FALSE as +1. If you use BOOL, all you can see is clouds of confusion over your application. so use VARIANT_BOOL(boolean type), VARIANT_TRUE(true),VARINAT_FALSE(false) Whenever you are using C++(COM), you should avoid using bool, BOOL in your application. Cheers, Anand:-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups