Click here to Skip to main content
12,953,700 members (47,772 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hello dears
because my English is bad i copy this from[^]

my question is exactly that is in below.


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
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
Rate this: bad
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.
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... :-)
Rate this: bad
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...
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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
ppolymorphe 2,020
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 15 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100