Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
Posted

C#
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
 
Share this answer
 
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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Jun-12 13:02pm    
My 4 (not 5), just because it needs correction: VB6 was obsolete even before it was presented to the market. Don't you thing so?
Other than that, I agree... :-)
--SA
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...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-Jun-12 13:05pm    
Well... you don't explain how to use the thread, especially in VB6. Besides, there is no such notion as "call a thread". So, what are you going to do "many times". I would like to hear that.
Please forgive me for this note, but you should not answer on the topics you don't understand. I just have to vote 1, sorry.
I only need to help you, I feel you are lost.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900