Page 1 of 1

VBA Operators \ and /

Posted: Tue Apr 21, 2009 10:49 am
by Steve Rowe
Just thought I'd put this out there for people as it's just tripped me up as I have spent a while debugging VBA trying to understand why a division was always producing an integer result.

Through force of habit of writing TM1 rules using the "\" to suppress divide by zero I'd written

applyValue = (Target.Value - currentTotal) \ 12

for some custom spreading functionality in VBA.

From the VBA help

/ Operator
Used to divide two numbers and return a floating-point result.

\ Operator
Used to divide two numbers and return an integer result.

I thought I had some kind of data type problem as I was not getting the result I wanted but I had used \ in error and should be using /.

I didn't even know that \ was valid in VBA.

Cheers,