Chapter 4: Programming Basics: Decisions and Looping


Overview

When writing programs, it's important to understand how programs make decisions and how they perform looping. Looping is the process of carrying out the same set of instructions until certain conditions are met.

Everyone is familiar with decisions. After all, you have to make them every day. For example when you wake up, which shirt do you decide to put on? You make this decision based on various facts such as what the weather is and what you are doing today. Your life would be very dull if you never had to make any decisions ‚ think what it would be like if it was already decided what shirt you wore each day!

Programs also have to make decisions based on parameters that the program has access to. The computer program would also be very dull if it never made a decision. For example, if a program tries to load a workbook file and the file is not found, a decision needs to be made as to what to do next . Should the program simply display an error message and crash, or should it show some intelligence and alert the user that the file is missing and offer an alternative action?

Artificial intelligence is something that is frequently discussed in computing circles. By making your programs make decisions, you are introducing some artificial intelligence into your program. Admittedly, it is your intelligence that goes into the code, but it tells the program what to do in the event of different circumstances happening. You are effectively writing a set of rules to deal with various situations.

Looping is also something you all do daily without thinking about it. When you eat a meal, you perform the same routine of taking food from a plate and putting it into your mouth. Computer programs frequently loop around the same piece of code a number of times until a certain condition is met.




Excel VBA Macro Programming
Excel VBA Macro Programming
ISBN: 0072231440
EAN: 2147483647
Year: 2004
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net