Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

In ActiveX Control calling functions defined in VB

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

Independent Software Vendors: 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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

650 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