Skip to Content
Programming Visual Basic 2005
book

Programming Visual Basic 2005

by Jesse Liberty
September 2005
Intermediate to advanced
576 pages
14h 23m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic 2005

Branching

Visual Basic 2005 statements are evaluated in order. The compiler starts at the beginning of a statement list and makes its way to the bottom. This would be entirely straightforward, and terribly limiting, were it not for branching .

Methods are executed from top to bottom. The compiler reads each line of code in turn, and executes one line after another. This continues in sequence until the method branches.

There are two ways a method can branch: unconditionally or conditionally. We'll look at each of these in turn.

Unconditional Branching Statements

The most common way to branch is by calling a method. This is an unconditional branch.

You call a method by writing its name. For example:

Method1()  'invokes Method1

Tip

It is also legal to call a VB.NET method with the optional keyword call:

call Method1()

If you do use call on a function, the return value is discarded. There is no advantage to this syntax, and it isn't used in this book.

Every time the compiler encounters a method call, it stops execution in the current method and branches to the newly called method. When that method returns, execution picks up in the original method on the line just below the method call, as illustrated schematically in Figure 16-2.

Branching schematic

Figure 16-2. Branching schematic

In Figure 16-2, execution begins in Main. Statements 1 and 2 execute and then the compiler sees a call to Method1. Program execution branches ...

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Programming Visual Basic 2008

Programming Visual Basic 2008

Tim Patrick
Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition

Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition

Paul J. Deitel - Deitel & Associates, Inc., Harvey M. Deitel - Deitel & Associates, Inc.

Publisher Resources

ISBN: 0596009496Errata Page