1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 10 - Using Modules and Procedures - Part 2

By Dan Mabbutt, About.com

6 of 7

Assignment Solution, Continued

In a larger system (where, presumably, the TryDisk Function would be called in many different places in the code), this allows the calling procedure to control which file is being checked. TryDisk returns a Boolean (that is, True/False) variable so it can be tested directly in an If block. In fact, some programmers would shorten the If statement even more by coding it as:

~~~~~~~~~~~~~~~~~~~~~~~~~
If TryDisk("a:\fileopen.bmp") Then Exit For
~~~~~~~~~~~~~~~~~~~~~~~~~

The Exit For statement is mentioned briefly in Chapter 9, but no example is shown. Here's your example!

Finally, the program uses the loop counter (in this case, the variable i) to determine whether the loop has completed or not. The rest of the code is on the next page.

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Using Modules and Procedures - Part 2

©2009 About.com, a part of The New York Times Company.

All rights reserved.