Book contents
- Frontmatter
- Contents
- Preface
- 1 Fundamentals of Design and Programming – Starting from Scratch
- 2 Variables and Constants – A Place for Everything and Everything in Its Place
- 3 Writing Programs – First You Walk, Then You Run
- 4 Writing Programs II – More Controls and New Logic
- 5 Using If and Case – Decisions, Decisions, Decisions
- 6 Loops – Once Is Not Enough
- 7 Procedures and Functions – Divide and Conquer
- 8 Writing Programs III – Tying It All Together, So Far
- 9 File I/O – Files and Records and Fields, Oh My!
- 10 Arrays and Structures – Organizing Data
- 11 Events and More Controls – Tips and Tricks for Programming
- 12 Objects and Classes – Objects Are in a Class By Themselves
- 13 Graphics – The Visual (and Audio) Side of Visual Basic
- 14 LINQ to SQL – The World Runs on Databases
- 15 Crystal Reports – Tying Databases to Output
- Appendices
- Index
5 - Using If and Case – Decisions, Decisions, Decisions
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- 1 Fundamentals of Design and Programming – Starting from Scratch
- 2 Variables and Constants – A Place for Everything and Everything in Its Place
- 3 Writing Programs – First You Walk, Then You Run
- 4 Writing Programs II – More Controls and New Logic
- 5 Using If and Case – Decisions, Decisions, Decisions
- 6 Loops – Once Is Not Enough
- 7 Procedures and Functions – Divide and Conquer
- 8 Writing Programs III – Tying It All Together, So Far
- 9 File I/O – Files and Records and Fields, Oh My!
- 10 Arrays and Structures – Organizing Data
- 11 Events and More Controls – Tips and Tricks for Programming
- 12 Objects and Classes – Objects Are in a Class By Themselves
- 13 Graphics – The Visual (and Audio) Side of Visual Basic
- 14 LINQ to SQL – The World Runs on Databases
- 15 Crystal Reports – Tying Databases to Output
- Appendices
- Index
Summary
VB Quip
The best thing about a Boolean is even if you are wrong, you are only off by a bit.
– AnonymousWhat 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 2010The Very Beginner's Guide, pp. 144 - 183Publisher: Cambridge University PressPrint publication year: 2010
- 1
- Cited by