ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   is it possible to pass a reference to a function as an argument (https://www.excelbanter.com/excel-programming/405153-possible-pass-reference-function-argument.html)

SlowArrow

is it possible to pass a reference to a function as an argument
 
I'd like to write a vba function, referencable by an argument of a vba
subroutine.
I think, the answer is NO, but i'd like to be sure about it.
I may avoid it, but it would be nice.

Thanks, ahead:-)

SlowArrow

Jim Cone

is it possible to pass a reference to a function as an argument
 
Huh ?
Helpful posting advice here... http://www.cpearson.com/excel/newposte.htm
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"SlowArrow"
wrote in message
I'd like to write a vba function, referencable by an argument of a vba
subroutine.
I think, the answer is NO, but i'd like to be sure about it.
I may avoid it, but it would be nice.

Thanks, ahead:-)

SlowArrow

Jim Thomlinson

is it possible to pass a reference to a function as an argument
 
I am a little unclear what exactly you want to do. Do you want to pass a
subroutine as an argument to a function (this would be similar to the ability
in C to pass a function as an argument). If that is what you are looking to
do then the answer is no. Perhaps a better explanation of what you would like
to accomplish will allow us to provide you with a satisfactory answer
though...
--
HTH...

Jim Thomlinson


"SlowArrow" wrote:

I'd like to write a vba function, referencable by an argument of a vba
subroutine.
I think, the answer is NO, but i'd like to be sure about it.
I may avoid it, but it would be nice.

Thanks, ahead:-)

SlowArrow


SlowArrow

is it possible to pass a reference to a function as an argumen
 
Dear Jim,

I appreciate your effort to help me. What I was looking for, is really the
c-like calling of the subroutines:-( Such is the life;-) I've seen some signs
(but not direct statements) in the vba help, and I saw some samples on the
internet to handle vba-written callback functions (here there were also
notices, which told me a strong no). However, people always hope some more
beautiful;-)

The problem, what indicated my question is the following, shortly:
I have just written a pretty userform with the mscal.ocx to to fill a
combobox (or textbox, but this is not important) called from the control's
MouseDown event. It works, but sometimes it is not enough to fill the box
with the selected date: I have to transform it a bit somehow (for example,
instead of writing the selected date, we have to put the first day of the
week containing the selected date into the control). Instead of wiring in the
code of the Calendar userform (at least a parameterizable code), I thought a
function passing feature would be the most general and elegant. So, this is
why i wanted to be sure about it.

Thanks for your help, again:-)

SlowArrow

"Jim Thomlinson" wrote:

I am a little unclear what exactly you want to do. Do you want to pass a
subroutine as an argument to a function (this would be similar to the ability
in C to pass a function as an argument). If that is what you are looking to
do then the answer is no. Perhaps a better explanation of what you would like
to accomplish will allow us to provide you with a satisfactory answer
though...
--
HTH...

Jim Thomlinson


"SlowArrow" wrote:

I'd like to write a vba function, referencable by an argument of a vba
subroutine.
I think, the answer is NO, but i'd like to be sure about it.
I may avoid it, but it would be nice.

Thanks, ahead:-)

SlowArrow



All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com