Using a VB OCX with C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jigo
    New Member
    • Aug 2009
    • 4

    Using a VB OCX with C#

    Hi! I have a VB OCX that I plan to use with C# 2008. The Events I created are visible at C# from the OCX. My problem is: the global functions from the OCX are not visible at C#. How can I fix this? All suggestions are welcomed. Thanks in advance.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Encapsulate the functions in some sort of public static class
    (You might only need to explicitly declare them public)

    Comment

    • Jigo
      New Member
      • Aug 2009
      • 4

      #3
      Thank you for your idea.

      The codes from my OCX are declared as Public, unless I am doing it incorrectly. Sample code is as follows:

      Code:
      Public Sub DisconOPC()
            OPCData.Disconnect
      End Sub
      I was expecting that DisconOPC is visible from my C# codes, but can't seem to make it work right.

      Comment

      • Jigo
        New Member
        • Aug 2009
        • 4

        #4
        Ok... here's what I found out. I started a fresh project. Using the same OCX, I finally have the public functions from the OCX showed up at C#. The problem persists with my original code which I could not afford to dispose now since I've written tons of codes.

        Any idea why the global functions are not visible at my original project? Thanks in advance.

        Comment

        • Jigo
          New Member
          • Aug 2009
          • 4

          #5
          I think I found the cause of the problem. My custom toolbars has something to do with it. I removed my toolbars and... whoaaa!! the global functions showed up!

          Comment

          Working...