Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 1 Exploring the Visual Studio Integrated Development Environment 33


is a setting that requires you to declare a variable before using it in a program—a very
good programming practice that I want to encourage. Option Strict Off allows variables
and objects of different types to be converted in certain circumstances without
generating a compiler error. (For example, a number can be assigned to a text box
object without error .) Although this is a potentially worrisome programming practice,
Option Strict Off is a useful setting for certain types of demonstration programs. If you
don’t keep this setting, a few projects will display error messages when you run them.
Option Compare determines the comparison method when different strings are
compared and sorted. For more information about comparing strings and sorting text,
see Chapter 13, “Exploring Text Files and String Processing .”
Option Infer was a new setting in Visual Basic 2008. When you set Option Strict to Off
and Option Infer to On, you can declare variables without explicitly stating a data type;
or rather, if you make such a declaration, the Visual Basic compiler will infer (or take
an educated guess) about the data type based on the initial assignment you made for
the variable. The designers of Visual Basic created this setting to make writing code
easier while still maintaining the benefits of type declaration. You’ll learn more about
the feature in Chapter 5, “Visual Basic Variables and Formulas, and the .NET
Framework .”
As a general rule, I recommend that you set Option Infer to Off to avoid unexpected
results in how variables are used in your programs. I have set Option Infer to Off in
most of the sample projects included on the companion CD.


  1. Feel free to examine additional settings in the Options dialog box related to your
    programming environment and Visual Studio. When you’re finished, click OK to close
    the Options dialog box.
    You’re ready to exit Visual Studio and start programming.


One Step Further: Exiting Visual Studio


Each chapter in this book concludes with a section titled “One Step Further” that enables
you to practice an additional skill related to the topic at hand. After the “One Step Further”
tutorial, I’ve compiled a Quick Reference table in each chapter that reprises the important
concepts discussed in the chapter, so that if you need to refer to a concept quickly, you can
have ready access to it.

When you’re finished using Visual Studio for the day, save any projects that are open,
and close the development environment. Give it a try.
Free download pdf