Making Decisions in Code
One of the most important statements in a program is the If statement. With the logic that If provides, your application can begin to analyze data and make decisions based on the analysis. For example, your program can display a three-button message box and determine, with the If statement, which command button the user should click to close the message box.
If uses the comparison operators you learned in the previous chapters, such as < and >=. If performs one of two possible code actions, depending on the result of the comparison. In other words, If uses a comparison operator result to test data and might execute one or more lines of subsequent code, depending on the result.
Before If, code was executed sequentially, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access