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

问题描述

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

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

我的问题正好在下面.

谢谢

我需要通过VB6中的功能指针来调用函数,而无需使用C编写的DLL的干预.这可能吗?我现在拥有的是:
公众回呼只要
公用callBackInterval只要




公共函数setCallBack(functionPtr为Long,可选间隔为Long = 100)为Long
callBack = functionPtr
callBackInterval =间隔
最终功能

''设置回调
setCallBack addressOf myCallBackFunction


''在代码中的其他地方调用回调
呼叫callBack" ERROR预期的过程,不是变量"

尝试通过指示预期过程,而非变量"的指针调用该函数时,将生成错误.我可以强制转换/转换此变量以使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调用函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 20:46
查看更多