×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

IF vs IIF in Equations

IF vs IIF in Equations

IF vs IIF in Equations

(OP)
Just discovered the IF operator can now be used in SW12, as opposed to the IIF operator in previous versions.

SW11
http://help.solidworks.com/2011/English/solidworks/sldworks/legacyhelp/sldworks/parts/operators_and_constants.htm

Quote:

You can also use the Visual Basic IIf function when specifying a model dimension. This function returns one of two values depending on the evaluation of an expression. For example, if the equation specified is "D1@Sketch1" = (IIf("D1@Sketch4">15, 20, 10)) + 8, then:

SW12
http://help.solidworks.com/2012/English/SolidWorks/sldworks/r_visual_basic_if_function.htm?id=c32893b7fc3e4458bde5678f355f3c20#Pg0

Quote:

You can also use the Visual Basic If function when specifying a model dimension.

This function returns one of two values depending on the evaluation of an expression.

For example, if the equation specified is "D1@Sketch1" = (If("D1@Sketch4">15, 20, 10)) + 8, then:

Anyone know of other changes?

RE: IF vs IIF in Equations

I don't have SW12 installed yet, but my guess is that since the syntax is completely unchanged other than changing IIf to If, nothing is really changed.  All equations actually get evauluated as a line of VBA code.  SolidWorks already looks for certain strings in the equation (dim names, custom prop names, etc) and replaces them with something else (a number/value) before handing them off to the VBA interpreter.  They just added " If(" to the list and replace it with " IIf(" before handing it off to the VBA interpreter.  They probably did that because too many people didn't understand why they spelled "if" with two 'i's.  smile

See what happens with the equation:

"dummy" = MsgBox("Hello World If(")

It wouldn't surprise me one bit if you got a message box that says:

Hello World IIf(

-handleman, CSWP (The new, easy test)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources