Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

Commands: Conditional

Unlike many programming languages, Visual Basic has been designed to focus on readability and clarity. Many languages are willing to sacrifice these attributes. Visual Basic is designed under the paradigm that the readability of code matters, so commands in Visual Basic tend to spell out the exact context of what is being done.

Literally dozens of commands make up the Visual Basic language, so there isn't nearly enough space here to address all of them. Moreover, many of the more specialized commands are covered later in this book. However, in case you are not familiar with Visual Basic or are relatively new to programming, this book will touch on a few of these. In this chapter, it makes the most sense to review the syntax of conditional statements.

Each of these statements has the ability to literally encapsulate a block of code. Of course the preferred way of embedding code within the scope of a conditional or loop is to call another method. Using a method within your loop or conditional helps keep your structure apparent and simple to view, and allows for code reuse if the same actions need to be accomplished from another location within your code.

Note that the variables declared within the context of a conditional statement (between the If and End If lines) are available only up until the End If statement. After that, these variables go out of scope. The concept of scoping is discussed in more detail later in this chapter.

If Then

The conditional is ...

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.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book