Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to F to C    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Short Circuit Evaluation
Maggie M 
     
2 years ago
Thank you for all your great lessons; I am truly a better programmer thanks to you. When I learned to program using punched cards (remember them? LOL), we were taught to do IfThenElse by using the most common option a user would need 1st so it wouldn't have to evaluate the 2nd option to save processing cycles. In your example, you check for Null 1st so it always has to process that option. Shouldn't you write it as follows . . .  
    If Not IsNull(TempF) Then
      FtoC = Round((TempF - 32) * 5 / 9, DecimalPlaces)
    Else
      FtoC = Null
    End If
. . . or doesn't it matter with today super-fast computers?
Sami Shamma  @Reply  
             
2 years ago
Hi Maggie,

I also did my early programming work on punch cards. The computers were so limited that even the programs were on punch cards. We needed to load the program, link it, compile it, run it, and take it out of memory before moving on to the next program. So, I know exactly what you're talking about.

Having said that, with today's computers, you can't measure the difference, not even in milliseconds. So, it's far better to write the  "if-then-else" statement to make it more readable than to gain 1 millionth of a second in speed.
Richard Rost  @Reply  
          
2 years ago
What you're talking about is something called short circuit evaluation. Basically, the processor stops evaluating the rest of the statement as soon as it reaches something that allows it to be done. So, in your case, if you have mostly null values, you might want to check for those first. As far as saving processor cycles go, it doesn't matter for average everyday stuff. But, if you're running code against 100,000 records and you have to check each one of them, then yes, you might want to do some short circuit evaluation.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in F to C.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 11:11:06 AM. PLT: 1s