Results 1 to 4 of 4

Thread: How do I access functions in an OCX?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    4

    Question

    Hello,

    I created an OCX file in C++. It contains a couple of functions each of which have arguments and return values.

    After registering the OCX and putting it on the ToolBox in VB6....what must I do to be able to use the functions?

    I have tried the following:
    Dim Var1 As MyFunctLib.Myfunct

    where Var1 is a new label
    MyFunctLib is the name of the ocx library
    Myfunct is the name of the OCX "Toolbox object"

    Then I added the following line...
    Var2 = Var1.GetData(1)

    where Var2 is a new variable
    GetData(1) is a function in the Myfunct Object

    In this example, the C function I am accessing looks like this:
    short GetData(short VarName)
    {
    if(VarName == 1)
    return(1)
    else
    return(0)
    }


    Question: Is there something I need to do to "Reference" the object in the VB project before using it?

    I cannot find any examples showing the implementation of an OCX function with parameters in VB. Any help is appreciated

    Thanks Much!
    Bob Bouthillier

  2. #2
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    I'm not sure, but isn't an OCX an ActiveX control? I think what you need is a DLL.
    Donald Sy - VB (ab)user

  3. #3
    Guest
    Well, yes.

    If you've created your function inside the Usercontrol and declared it Public, then you can use:

    var = userctlname.FunctionName(Params)

    AFTER you've added the usercontrol to your form.

    OR, you can find yourcontrolname in the REFERENCES, or BROWSE for it.

    I agree with dsy5, using a AXDLL is MUCH easier.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    4
    Thanks for the advice to pursue it as a AXDLL.

    I've now created a dll with automation and put the same function into it. However, since I'm a C/C++ programmer, and not a VB programmer, I don't know how to properly declare the function and use it in VB6.

    Can anyone help with this?

    Thanks.

    Bob

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