Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6function
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 13-Feb-12 3:47am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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...
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 390
1 Shai Vashdi 349
2 Sergey Alexandrovich Kryukov 325
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 8,979
1 OriginalGriff 5,280
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 15 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid