?
Solved

In ActiveX Control calling functions defined in VB

Posted on 2000-03-04
5
Medium Priority
?
204 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 300 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 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