VBA value check not working for .Fill.Transparency in PowerPoint 2013

This is weird and driving me nuts.

If I open PowerPoint and add a rectangle to a slide, set its transparency to 10% via the PowerPoint UI (Format Shape pane) and then do this in the VBE immediate window while the shape is selected:


Open in new window

I see the expected result of 0.1

But what is going on here?


Open in new window

The transparency property returns a value of type Single so I tried these:


Open in new window

And weirdly this works:

Open in new window

I then tried this:

Open in new window

So why is 10% not equal to 0.1?
LVL 14
Jamie GarrochPowerPoint Consultant & DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
because that value is stored as double precision, which tends to contain rounding errors.

Keep in mind, that all number (including decimals) are represented as 0's and 1's.  I've never really understood how the decimals are handled but Access does not store the value of 0.1, it stores a binary representation of that number.  Whenever I need to compare two numbers, one of which is a decimal, I usually do something like:

?Abs(ActiveWindow.Selection.ShapeRange(1).Fill.Transparency - 0.1) < 0.0001

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft PowerPoint

From novice to tech pro — start learning today.