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:

?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency
 0.1 

Open in new window


I see the expected result of 0.1

But what is going on here?

?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=0.1
False

Open in new window


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

?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=0.1!
False
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency=CSng(0.1)
False

Open in new window


And weirdly this works:
?Val(ActiveWindow.Selection.ShapeRange(1).Fill.Transparency)=0.1
True

Open in new window


I then tried this:
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency*100000
 1000000.23841858 

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

x
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
0

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
Rgonzo1971Commented:
Or
?ActiveWindow.Selection.ShapeRange(1).Fill.Transparency-cdec(.1)=0
0
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.