Solved

In ActiveX Control calling functions defined in VB

Posted on 2000-03-04
5
200 Views
Last Modified: 2013-11-20
I want to write an ActiveX control which can call some self-defined subs or functions in vb,I tried, but when never I use the control in vb,it raise the error "automation error".

Here's my code:
//in vc++
TYPEDEF void (CALLBACK* MYPROC)(LPTSTR);

//one method of my control
BOOL DoSomething(long FuncAdd)
{
    ((MYPROC)FuncAdd)(_T("TestString"));
}

//in vb
//sub in a module
sub testsub(a as string)
   msgbox a
end sub

//in a form
sub Command1_Click()
    mycontrol.DoSomething AddressOf testsub
end sub

Could you give me some suggestions?
0
Comment
Question by:ycl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2582738
listening....
0
 
LVL 32

Expert Comment

by:jhance
ID: 2582817
Of course this is an automation error since you don't have an automation interface in this VC++ program.

Automation interface is another name for the IDispatch COM interface and you must implement this interface if you want to use it from Visual Basic.

My guess here is that you have no idea what I'm talking about and don't understand how VB works with controls and COM objects.

This might be a good place to start:

http://www.codeguru.com/atl/COM_ATL_Tutorial.shtml
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2583281
inpras, there's no need to announce to the world that you're listening.  Just leave the "Post a comment" box blank, mark the "check here" box, and press the "Submit" button.  You'll be subscribed without firing off an unneeded notification to everyone else.

..B ekiM
0
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 2599882
So you reject my answer without any comment.  I can only assume you didn't read it...


Of course this is an automation error since you don't have an automation interface in this VC++ program.

Automation interface is another name for the IDispatch COM interface and you must implement this interface if you want to use it from Visual Basic.

My guess here is that you have no idea what I'm talking about and don't understand how VB works with controls and COM objects.

This might be a good place to start:

http://www.codeguru.com/atl/COM_ATL_Tutorial.shtml
0
 

Author Comment

by:ycl
ID: 2602821
I have solved this problem,only because I should have declared the parameters of the function in VB using Byval
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question