Currency formatting not being applied to cell with user defined basic formula

Currency formatting is not applied to calc cells which contain user defined formulas that return ‘Currency’ values.

For example, if you create the following basic function:

Function TestFunc() As Currency
	Dim Result As Currency
	Result = 5.50
	TestFunc = Result
End Function

Then use that function in a cell like =TestFunc(), the value ‘5.5000’ appears in the cell.

If I try to enforce the typical currency style by selecting the cell and going to ‘Format’ ‘Cells…’ And then double clicking the currency format I want, nothing happens. ‘5.5000’ continues to be displayed even though ‘$5.50’ ought to be displayed.

In addition, If you create several such cells and then try to sum over them with the =SUM function, the value is always ‘$0.00’.

Any ideas why this is happening?

I’m currently using libreoffice on Arch linux.

The BASIC Currency return type is not recognized as number but string instead, which seems to be a bug. To workaround, do not define it as Currency but return a normal number instead.

Submitted bug tdf#105558

For the records, fixed for 5.3.1 and 5.4.0.