Skip to main content Accessibility help
×
Hostname: page-component-7479d7b7d-t6hkb Total loading time: 0 Render date: 2024-07-13T02:24:05.000Z Has data issue: false hasContentIssue false

5 - Using If and Case – Decisions, Decisions, Decisions

Published online by Cambridge University Press:  05 June 2012

Jim McKeown
Affiliation:
Dakota State University
Get access

Summary

VB Quip

The best thing about a Boolean is even if you are wrong, you are only off by a bit.

Anonymous

What Are Decision Structures?

Decision structures give the computer a brain. Sort of. So far, every program has followed a sequence of commands. Every command has executed, in order, when needed. That's great if you're riding the kiddie cars at the carnival, but you want some real power and the ability to make your own decisions. Think open road, the wind in your face, and the power to take whatever road suits your fancy. That's where If and Case statements come in. Quite literally you'll be able to pick one path or the other with an If statement. With a Case statement, you'll be able to choose one path from many. Are you hungry? Do you need gas? Then stop. It's your decision. Without them, you're merely a passenger on the bus and someone else makes all the decisions. With them, you turn the computer from a calculator that can only solve one problem into a thinking machine that can make decisions for various outcomes based on the input provided and the directions given to it by the developer. In short, you're on your way to teaching the computer how to think.

If…Then…Else Structures

Decision structures give the computer multiple blocks of code and the ability to select the block of code to execute.

Type
Chapter
Information
Programming in Visual Basic 2010
The Very Beginner's Guide
, pp. 144 - 183
Publisher: Cambridge University Press
Print publication year: 2010

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×