https://bugs.documentfoundation.org/show_bug.cgi?id=101631

--- Comment #10 from Joshua Coppersmith <joshua_coppersm...@hotmail.com> ---
As usual, Eike not only gives an explanation, but also a workaround. And kudo's
for the bug...I've never seen anything quite as dynamic as constant number
entries changing before my eyes!

However, I think I have something to add here.

In VBA Variants act a lot like reference names (i.e. wrappers). Even if you
pass a Variant using the ByVal keyword that may not give expected results.
However, if you pass Integers you will get pass-by-value behavior (I seem to
remember, I've moved on to native LO :) ). So instead of

Function stableford(score, hcp, ...

use

Function stableford(score As Integer, hcp As Integer, ...

and to be really sure, use

Function stableford(ByVal score As Integer, ByVal hcp As Integer, ...

I modified the example Excel workbook only by changing the stableford signature
 to this "really sure" version and then could not reproduce any peculiarities,
neither Err:522 nor magic changing numbers.

There used to be a trick of putting caller parameters in parentheses when
calling from code to code in VB, to force a calculation before the caller
parameters were put on the VB stack, sort of defeating ByRef behavior in the
called function. (If I remember correctly...) You can't do that directly from a
spreadsheet, of course, so you have to armor-plate the function signature
itself.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to