VBA Operators \ and /

Ideas and tips for enhancing your TM1 application
Post Reply
User avatar
Steve Rowe
Site Admin
Posts: 2410
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

VBA Operators \ and /

Post 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,
Technical Director
www.infocat.co.uk
Post Reply