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
Solved

In ActiveX Control calling functions defined in VB

Posted on 2000-03-04
5
196 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 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