-
ME.?
In an arbitary function. Could I pass a reference to it to another function?
function f1 (nVal as Integer)
nNewVal = nVal + 1
f2(me)
end function
function f2(hFunction as Object)as Integer
f2 = hFunction.nNewVal + 1
end function
Is this sort of thing possible... I know with the ME keyword you may have access to all the objects etc.. but how do you get access to parameters that were passed to that function etc?
Thanks
Rob.
-
Re: ME.?
Functions aren't objects, so I don't think you could ever use the Me.
Hmmmm.... But what if you declared the function as an object? I suppose that only means that it's returning an object, but it its self isn't one.
I think this would be possible then...
Function f1 () as Object
...
f2(f1)
...
End Function
Function f2 (objFunct as Object) as Variant
...
I don't see how this could be used though, nor do I see how you would reference any properties, unless you set the function = to an object within its self. (That could be useful)
Brewguru99
-
Re: ME.?
If your aim is to use the nNewVal that is inside the fn F1 say something like
f2(nNewVal). If you want the parameters (modified/unmodified) of one function .. call the other fn from this function!, passing all the params.
And what you are doing is not allowed in VB. If you are thinking of trying "Function pointers of C" ( - from your example i dont think you are!!), it is not allowed from VB-VB calls.
And FUNCTIONS are not OBJECTS. Objects may contain (member) functions !!
RK
-
Re: ME.?
You can pass a procedure pointer with vb but I don't know what you'd do with it once you had it except for ship it off to an API.
Compliments of Bruce McKinney "Hardcore VB":
Function GetProc(proc as Long) as Long
GetProc= proc
End Function
then call the function like this:
procWindow =GetProc(AddressOf EnumWndProc)
or whatever procedure pointer you wanted.
Not really a solution to the question here but kind of a neat trick huh