回调函数-从VB6调用函数指针 [英] Callback functions - calling function pointers from VB6

查看:117
本文介绍了回调函数-从VB6调用函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,亲爱的
因为我的英语不好,所以我复制了

http://www.gamedev.net/topic /322545-vb6-callback-functions --- calling-function-pointers-from-vb6/ [
尝试通过指示预期过程,而非变量"的指针调用该函数时,将生成错误.我可以强制转换/转换此变量以使VB6保持安静吗?在VB6中甚至可以这样做吗? TY

hello dears
because my English is bad i copy this from

http://www.gamedev.net/topic/322545-vb6-callback-functions---calling-function-pointers-from-vb6/[^]

my question is exactly that is in below.

thanks

I need to call a function through a functionpointer from within VB6, without the intervention of a DLL written in C. Is this possible? What I have now:
public callBack as long
public callBackInterval as long




Public Function setCallBack(functionPtr As Long, Optional interval As Long = 100) As Long
callBack = functionPtr
callBackInterval = interval
End Function

'' setting callback
setCallBack addressOf myCallBackFunction


'' Calling the callback somewhere else in the code
Call callBack '' ERROR "expected procedure, not variable"

An error is generated when trying to call the function throught the pointer saying "Expected procedure, not variable". Can I cast/convert this variable to keep VB6 quiet? Is it even possible to do this in VB6? TY

推荐答案

so what
this mean that we does not have function pointer in vb?
in this With these conditions we can not pass a function pointer to another function

for example in c++ we have function pointer and can call it.

int sum(int x1,int x2){
return x1+x2;
}

int sub(int x1,int x2){
return x1+x2;
}

int f(int p1,int p2,int (*x(int,int))){
 return x(p1,p2);
}

int main(){
cout<<f(5,10,sum);//in this line print  15
cout<<f(5,10,sub);//in this line print  -5
}

i want do some work in vb. how do i do this?

excuse me for my English

thank you very much


VB6很糟糕.它已经过时了十年.没有C ++的帮助,VB6永远无法做任何特别有用的事情.如果您想使用过时的语言(肯定不适合编写游戏),则可能需要在某个时候编写一些C ++代码以使其按您的意愿进行.我认为您说的是不使用C ++"是因为您已经找到了一种使用C ++进行编码的方法,所以您本质上是在问,我知道该怎么做,但我想知道如何如果我没有使用正确的工具来完成工作,那就去做.

您的链接指向同一个问题,而不是任何解决方案.这个问题是在2005年提出的,但是没有答案. VB6那时已经过时了,尚未更新.如果没有答案,那就不可能再有答案了.
VB6 is crap. It has been obsolete for a decade. VB6 has never been able to do anything particularly useful without help from C++. If you want to use an obsolete language, which is certainly not suitable for writing games, you probably need to write some C++ code at some point to make it do what you want it to. I assume the fact you''re saying ''without C++'' is because you''ve found a way to do it WITH C++, so you''re essentially asking, I know how to do this but I want to know how to do it if I don''t use the right tools for the job.

Your link is to the same question, not any solution. That question was asked in 2005 and got no answer. VB6 was already obsolete then and has not been updated. If there was no answer then, there''s not likey to be one now.


我的想法是寻求线索.......
您必须创建线程并在任意次数的任何地方调用它...不用麻烦.......
我建议你这是最好的方法...
My idea here to go for threads .......
u have to create the thread and call it any where any number of times... not a bother.......
I suggest u this is the best way...


这篇关于回调函数-从VB6调用函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆