Stephens' Visual Basic Programming 24-Hour Trainer

( 2 )

Overview

Unique book-and-DVD package for novice Visual Basic programmers

Start from scratch, and even if you don?t know a thing about Visual Basic, you soon will with this thorough introduction to Visual Basic programming. Using easy-to-follow lessons and step-by-step instruction, this practical book teaches you concepts and hands-on techniques, then reinforces your learning with video screencasts and supplemental materials. Follow the exercises, then access the Try It section on the ...

See more details below
Paperback
$29.06
BN.com price
(Save 27%)$39.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (10) from $14.99   
  • New (7) from $14.99   
  • Used (3) from $15.06   
Sending request ...

Overview

Unique book-and-DVD package for novice Visual Basic programmers

Start from scratch, and even if you don?t know a thing about Visual Basic, you soon will with this thorough introduction to Visual Basic programming. Using easy-to-follow lessons and step-by-step instruction, this practical book teaches you concepts and hands-on techniques, then reinforces your learning with video screencasts and supplemental materials. Follow the exercises, then access the Try It section on the DVD, and watch as well-known VB authority and author Rod Stephens works through programming problems.

  • Introduces Visual Basic programming to beginning programmers; no prior experience is necessary
  • Covers Visual Basic programming concepts and techniques, as well as the Visual Studio development environment
  • Provides a series of easy-to-follow lessons, supplemented by instructional video on DVD
  • Offers expert instruction from well-known VB authority and author Rod Stephens, who also provides supplemental instruction on the DVD, where he works through a series of Try It problems and demonstrates effective solutions

Stephens' Visual Basic Programming 24-Hour Trainer is an exceptional book-and-DVD package that will have you programming in Visual Basic in no time.

Note: As part of the print version of this title, video lessons are included on DVD. For e-book versions, video lessons can be accessed at wrox.com using a link provided in the interior of the e-book.

Read More Show Less
  • Stephens' Visual Basic...
    Stephens' Visual Basic...  

Product Details

  • ISBN-13: 9780470943359
  • Publisher: Wiley
  • Publication date: 2/8/2011
  • Edition number: 1
  • Pages: 504
  • Sales rank: 459,350
  • Product dimensions: 7.30 (w) x 9.10 (h) x 1.20 (d)

Meet the Author

Rod Stephens is a Microsoft MVP and the author of more than 20 books and 250 articles on Visual Basic, C#, Java, and other programming topics. He is a regular contributor to DevX and the author of the bestselling Visual Basic Programmer's Reference.

Read More Show Less

Read an Excerpt

Stephens' Visual Basic Programming 24-Hour Trainer


By Rod Stephens

John Wiley & Sons

Copyright © 2011 John Wiley & Sons, Ltd
All right reserved.

ISBN: 978-0-470-94335-9


Chapter One

Getting Started with the Visual Studio IDE

The Visual Studio integrated development environment (IDE) plays a central role in Visual Basic development. In this lesson you explore the IDE. You learn how to configure it for Visual Basic development, and you learn about some of the most useful IDE windows and what they do. When you finish this lesson, you'll know how to create a new project. It may not do much, but it will run and you'll be ready for the lessons that follow.

Visual Studio is a development environment that you can use with several programming languages, including C#, Visual Basic, Visual C++, and F#. Visual Basic is a high-level programming language that can read inputs, calculate results, display outputs to the user, and perform other operations typical of high-level programming languages.

The .NET Framework also plays an important role in Visual Basic programs. It includes classes that make performing certain tasks easier, runtime tools that make it possible to execute Visual Basic programs, and other plumbing necessary to build and run Visual Basic programs.

Normally you don't need to worry about whether a feature is provided by Visual Studio, the Visual Basic language, or the .NET Framework. They all go together in this book, so for the purposes of this book at least you can ignore the difference.

INSTALLING VISUAL BASIC

Before you can use Visual Basic to write the next blockbuster first-person game, you need to install it, so if you haven't done so already, install Visual Basic.

You can install the Express Edition from www.microsoft.com/express/Windows. If you think you need some other version (for example, you're working on a big project and you need test management, source code control, and other team programming tools), go to Microsoft's Download Center at www.microsoft.com/downloads and install the version that's right for you.

It's a big installation, so downloading it could take a while.

CONFIGURING THE IDE

When you first run Visual Studio, it asks how you want to configure the IDE. You can pick settings for general development, Visual Basic, Visual C#, and so forth. Because you're going to be focusing on Visual Basic development, select that option.

If you ever want to switch to different settings (for example, if you got carried away during installation and selected the general settings and now want the Visual Basic settings), you can always change them later.

To change the settings later, open the Tools menu and select Import and Export Settings to display the Import and Export Settings Wizard. You can use this tool to save your current settings, reload previously saved settings, or reset settings to default values.

To reset settings for Visual Basic, select the Reset All Settings option on the wizard's first page and click Next.

On the next page, indicate whether you want to save your current settings. When you've made your choice, click Next to display the page shown in Figure 1-1. Select the Visual Basic Development Settings option and click Finish. (Then sit back and wait. Or, better still, go get a coffee because this could take a while. Visual Studio has a lot of settings to reset, and it could take several minutes depending on how fast and busy your computer is.)

BUILDING YOUR FIRST PROGRAM

Now that you've installed Visual Basic, you're ready to get started. Launch Visual Studio by doubleclicking its desktop icon or by selecting it from the system's Start menu.

To create a new project, press [Ctrl]+N to display the New Project dialog box shown in Figure 1-2. Alternatively, you can open the File menu and select New Project.

Expand the Visual Basic project type folder on the left and select the template for the type of project that you want to build on the right. For most of this book, that will be a Visual Basic Windows Forms Application.

Below the list of project types, you need to enter the name that you want to give the application. It's not completely trivial to change the name later so take a moment to pick a good one.

Initially Visual Studio creates the new project in a temporary directory. If you press [Ctrl]+[Shift]+S or select the File menu's Save All command, the Save Project dialog shown in Figure 1-3 appears.

On this dialog you need to enter three key pieces of information:

* Name — This is the application's name. Visual Studio creates a folder with this name to hold the program's files. This name also gets built into the program in several places so later it can be hard to change every occurrence correctly. This is pretty advanced so I won't cover them here. Fortunately, the difference is seldom a problem, but it's usually better to just pick a good name when you start and stick with it.

* Location — This is where you want Visual Studio to put the project's folder.

* Solution Name — If the Create Directory for Solution box is checked (which it is by default), Visual Studio creates a folder with this name at the Location you entered. It then places the application's folder inside the solution's folder.

Therefore, if the Create Directory for Solution box is checked, you get a filesystem layout that looks like this:

SolutionFolder

SolutionFiles

ApplicationFolder

ApplicationFiles

If the Create Directory for Solution box is not checked, you get a filesystem layout that looks like this:

ApplicationFolder

ApplicationFiles

All of the applications you build in this book are single programs so they don't really need to be inside a separate solution folder. Most of the time, I uncheck the Create Directory for Solution box to keep my filesystem simpler.

After you create a new project, the result should look like Figure 1-4.

The rest of this lesson deals with the features available in Visual Studio, some of which are displayed in Figure 1-4. Before you launch into an inventory of useful features, however, press F5 or open the Debug menu and select Start Debugging to run your new program. Figure 1-5 shows the result. Admittedly, this first program isn't very fancy, but by the same token you didn't need to do much to build it.

This first program may not seem terribly impressive but there's a lot going on behind the scenes. Visual Basic has built a form with a bunch of useful features, including the following:

* A resizable border and draggable title bar.

* Minimize, maximize, and close buttons in the upper-right corner.

* A system menu in the upper-left corner that contains the commands Restore, Move, Size, Minimize, Maximize, and Close.

* An icon in the system taskbar.

* The capability to use [Alt]+[Tab] and Flip3D ([Win]+[Tab]) to move between the application and others.

* Other standard window behaviors. For example, if you double-click the form's title bar, it maximizes (or restores if it is already maximized); and if you press [Alt]+F4, the form closes.

* Different appearances depending on the operating system and the theme you're using.

Unless you're an absolute beginner to Windows, you probably take all of these features for granted, but providing them is actually a lot of work. Not too long ago you would have had to write around 100 lines of code to handle these sorts of issues. Now Visual Studio automatically builds a form that handles most of these details for you.

You can still get in and change the way things work if you want to (for example, you can set a form's minimum and maximum sizes), but usually you can ignore all these issues and concentrate on your particular application, not the Windows decorations.

COPYING PROJECTS

Sometimes you may want to copy a project. For example, you might want to save the current version and then make a new one to try things out. Or you may want to give a copy of the project to a friend or your programming instructor.

To make a copy, you might look in the File menu and see the Save As commands. Don't be tempted! Those commands copy single files, not the entire project. Later when you try to open one of those files, you'll discover that Visual Studio cannot find all of the other project pieces that it needs and you'll be left with nothing usable.

To correctly copy a project, find the solution or application folder in Windows Explorer and copy the project's entire directory hierarchy. Alternatively, you can compress the project directory into a zipped file and then copy that. Just be sure that whatever copying method you use brings along all of the project's files.

Note that you can delete the bin and obj subdirectories if you'd like to save space. Visual Studio will recreate them whenever it needs them later.

EXPLORING THE IDE

The Visual Studio IDE contains a huge number of menus, toolbars, windows, wizards, editors, and other components to help you build applications. Some of these, such as the Solution Explorer and the Properties window, you will use every time you work on a program. Others, such as the Breakpoints window and the Connect to Device dialog box, are so specialized that it may be years before you need them.

Figure 1-6 shows the IDE with a simple project loaded and some of the IDE's most important pieces marked. The following list describes these pieces:

1. Menus — The menus provide all sorts of useful commands. Exactly which commands are available, which are enabled, and even which menus are visible depends on what kind of editor is open in the editing area (#4). Some particularly useful menus include File (opening old projects and creating new ones), View (finding windows), Project (adding new forms and other items to a project), Debug (build, run, and debug the project), and Format (arrange controls on a form).

2. Toolbars — The toolbars provide shortcuts for executing commands similar to those in the menus. Use the Tools menu's Customize command to determine which toolbars are visible.

3. Solution Explorer — The Solution Explorer lists the files in the project. One of the most important is Form1.vb, which defines the controls and code for the form named Form1. If you double-click a file in the Solution Explorer, the IDE opens it in the editing area.

4. Editing area — The editing area displays files in appropriate editors. Most often you will use this area to design a form (place controls on it and set their properties) and write code for the form, but you can also use this area to edit other files such as text files, bitmaps, and icons.

5. Toolbox — The Toolbox contains controls and components that you can place on a form. Select a tool and then click and drag to put a copy of the tool on the form. Notice that the Toolbox groups controls in tabs (All Windows Forms, Common Controls, Containers, Menus & Toolbars, and so on) to make finding the controls you need easier.

6. Properties window — The Properties window lets you set control properties. Click a control on the Form Designer (shown in the editing area in Figure 1-6) to select it, or click and drag to select multiple controls. Then use the Properties window to set the control(s) properties. Notice that the top of the Properties window shows the name (Label1) and type (System .Windows.Forms.Label) of the currently selected control. The currently selected property in Figure 1-6 is Text, and it has the value First Name:.

7. Property description — The property description gives you a reminder about the current property's purpose. In Figure 1-6, it says that the Text property provides the text associated with the control. (Duh!)

8. Other windows — This area typically contains other useful windows. The tabs at the bottom enable you to quickly switch between different windows.

Figure 1-6 shows a fairly typical arrangement of windows but Visual Studio is extremely flexible, so you can rearrange the windows if you like. You can hide or show windows; make windows floating or docked to various parts of the IDE; make windows part of a tab group; and make windows automatically hide themselves if you don't need them constantly.

If you look closely at the right side of the title bar above one of the windows in Figure 1-6, for example, the Properties window, you'll see three icons: a drop-down arrow, a thumbtack, and an X.

If you click the drop-down arrow (or right-click the window's title bar), a menu appears with the following options:

* Float — The window breaks free of wherever it's docked and floats above the IDE. You can drag it around and it will not redock. To make it dockable again, open the menu again and select Dock.

* Dock — The window can dock to various parts of the IDE. I'll say more about this shortly.

* Dock as Tabbed Document — The window becomes a tab in a tabbed area similar to #8 in Figure 1-6. Unfortunately, it's not always obvious which area will end up holding the window. To make the window a tab in a specific tabbed area, make it dockable and drag it onto a tab (described shortly).

* Auto Hide — The window shrinks itself to a small label stuck to one of the IDE's edges and its thumbtack icon turns sideways to indicate that the window is auto-hiding. If you float the mouse over the label, the window reappears. As long as the mouse remains over the expanded window, it stays put, but if you move the mouse off the window, it auto-hides itself again. To turn off auto-hiding, select Auto Hide again or click the sideways thumbtack. Auto-hiding gets windows out of the way so you can work in a bigger editing area.

* Hide — The window disappears completely. To get the window back, you'll need to find it in the menus. You can find many of the most useful windows in the View menu, the View menu's Other Windows submenu, and the Debug menu's Windows submenu.

The thumbtack in a window's title bar works just like the drop-down menu's Auto Hide command does. Click the thumbtack to turn on auto-hiding. Expand the window and click the sideways thumbtack to turn off auto-hiding. (Turning auto-hiding off is sometimes called pinning the window.)

The X symbol in the window's title bar hides the window just like the drop-down menu's Hide command does.

In addition to using a window's title bar menu and icons, you can drag windows into new positions. As long as a window is dockable or part of a tabbed window, you can grab its title bar and drag it to a new position.

As you drag the window, the IDE displays little drop targets to let you dock the window in various positions. If you move the window so the mouse is over a drop target, the IDE displays a translucent blue area to show where the window will land if you drop it. If you drop when the mouse is not over a drop target, the window becomes floating.

Figure 1-7 shows the Properties window being dragged in the IDE. The mouse is over the right drop target above the editing area; therefore, as the translucent blue area shows, dropping it there would dock the window to the right side of the editing area.

The drop area just to the left of the mouse represents a tabbed area. If you drop on this kind of target, the window becomes a tab in that area.

TRY IT

In this Try It, you prepare for later work throughout the book. You locate web resources that you can use when you have questions or run into trouble. You create and run a program, explore the project's folder hierarchy, and make a copy of the project. You also get a chance to experiment a bit with the IDE, displaying new toolbars, moving windows around, and generally taking the IDE for a test drive and kicking the tires.

Lesson requirements

In this lesson:

* Find and bookmark useful web resources.

* Launch Visual Studio and start a new Visual Basic project.

* Experiment with the IDE's layout by displaying the Debug toolbar, pinning the Toolbox, and displaying the Output window.

* Run the program.

* Find the program's executable, copy it to the desktop, and run it there.

* Copy the project folder to a new location and make changes to the copy.

* Compress the project folder to make a backup.

Hints

* When you create a new project, be sure to give it a descriptive name.

* When you save the project, put it in an obvious location so you can find it later.

* Before you compress the project, remove the bin and obj directories to save space.

(Continues...)



Excerpted from Stephens' Visual Basic Programming 24-Hour Trainer by Rod Stephens Copyright © 2011 by John Wiley & Sons, Ltd. Excerpted by permission of John Wiley & Sons. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Introduction.

Section I: The Visual Studio IDE and Controls.

Lesson 1: Getting Started with the Visual Studio IDE.

Lesson 2: Creating Controls.

Lesson 3: Making Controls  Arrange Themselves.

Lesson 4: Handling Events.

Lesson 5: Making Menus.

Lesson 6: Making Tool Strips and Status Strips.

Lesson 7: Using RichTextBoxes.

Lesson 8: Using Standard Dialogs.

Lesson 9: Creating and Displaying New Forms.

Lesson 10: Building Custom Dialogs.

Section II : Variables and Calculations.

Lesson 11: Using Variables and Performing Calculations.

Lesson 12: Debugg ing Code.

Lesson 13: Understanding Scope.

Lesson 14: Working with Strings.

Lesson 15: Working with Dates and Times.

Lesson 16: Using Arrays and Collections.

Lesson 17: Using Enumerations and Structures.

Section III : Program Statements.

Lesson 18: Making Choices.

Lesson 19: Repeating Program Steps.

Lesson 20: Reusing Code with Procedures.

Lesson 21: Handling Errors.

Lesson 22: Preventing Bugs.

Section IV: Classes.

Lesson 23: Defining Classes and Their Properties.

Lesson 24: Defining Class Methods and Events.

Lesson 25: Using Inheritance and Polymorphism.

Lesson 26: Initializing Objects.

Lesson 27: Fine-Tuning Classes.

Lesson 28: Overloading Operators.

Lesson 29: Using Interfaces.

Lesson 30: Making Generic Classes.

Section V: System Interactions.

Lesson 31: Reading and Writing Files.

Lesson 32: Using File System Classes.

Lesson 33: Printing.

Lesson 34: Using the Clipboard.

Lesson 35: Providing Drag and Drop.

Section VI: Specialized topics.

Lesson 36: Using the My Namespace.

Lesson 37: Localizing Programs.

Lesson 38: Manipulating Data with LIN Q to Objects.

Lesson 39: Manipulating  Databases with the Entity Framework.

Appendix A: Glossary.

Appendix B: Control Summary.

Appendix C: What's on the DVD?

Index.

Read More Show Less

Customer Reviews

Average Rating 5
( 2 )
Rating Distribution

5 Star

(2)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Posted August 29, 2011

    Highly recommended.

    I am currently 1/2 through the book. This book is well written. The explanations are clear and the examples are well done. So far all of the downloaded code has run without an error. The DVD lessons show the author working th 'Try It' exercises. It is worth watching all of them as he shows shortcuts that can make things easier. If you have questions you can ask them on the Wrox forum for this book. The author responded quickly to every one of my questions. When the answer wasn't readily noticeable from the code I posted he gave me his e-mial address to send him my code!! The author really supports you after you buy the book. This book is a great value for the price. I would highly recommend this to anyone wanting to learn Visual Basic. When I look for my next book I will definately look at Rod Stephens' books as I have thoroughly enjoyed the time I have spent reading this book and working the exercises. His writing style makes it easy to learn.

    1 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted August 11, 2011

    Great if your just starting out, or need a refresher.

    I am a huge fan of the layout of this book. Stephens has a great way of teaching you something, and then using those concepts throughout the rest of the book. By the end, even more complex concepts, you're able to see them in use and understand them quickly. With the added video tutorials and DVD content, this book is just an all-around great value.

    1 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)