dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 26, 1999

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Avoid IIf Inefficiencies

The IIf function-which returns one of two values determined by logical test-has this syntax: IIf(Expression, TruePart, FalsePart). At first, it might seem like an ideal shortcut for an If...Else...End If block. However, IIf is designed to execute both the True part and the False part. To verify, copy this into your Debug window and press enter:

 
? IIf(True, MsgBox("True Part"), MsgBox("False Part"))

Obviously, it's extremely inefficient-and possibly error-inducing-to place functions in the True and False parts of IIf, because they are both executed. In general, always use a standard If...Else...End If block instead.

William Wen
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date