Visio Guy

Visio Discussions => Programming & Code => Topic started by: music_al on April 29, 2008, 08:31:09 PM

Title: IF Statements in Shapesheet Cells
Post by: music_al on April 29, 2008, 08:31:09 PM
I have 2 Shape Data items: Device Name and Device Type

I want to set some rules in the Shapesheet, so lets use this example...

Fruit Types ="Banana;Apple;Orange"  *I am typing this in the FORMAT box
Fruit Colors =IF(Prop.Row_8="Banana","Yellow",IF(Prop.Row_8="Apple","Green",IF(Prop.Row_8="Orange","Orange","")))  *Will this formula work and if so, where do I type it ? I have tried it in the FORMAT and VALUE cell, but neither works.

Any ideas ?


Many thanks

Allan
Title: Re: IF Statements in Shapesheet Cells
Post by: Visio Guy on April 29, 2008, 09:04:20 PM
Hi music_al,

To compare strings, you'd do IF(StrSame(Prop.Fruit.Value,"Apple") Direct comparison of text in the ShapeSheet doesn't work.

Another structure that works is to use indices. That way you can change the format string without messing with your code:

Prop.Fruit.Format = "Banana;Apple;Orange"
Prop.Fruit.Value = "Apple"  (for example)

User.fruitIndex = LOOKUP(Prop.Fruit.Value, Prop.Fruit.Format)  ( = 0, 1, 2  or -1 )
User.color = IF(User.fruitIndex = 0, ...=1, ...=2)