Visual Basic 2008 FOR. DUMmIES. by Bill Sempf

Similar documents
ebay For Seniors Learn to: Marsha Collier Making Everything Easier! Get your own ebay account for buying and selling

Excel Formulas and Functions FOR. DUMmIES. by Ken Bluttman and Peter G. Aitken

Jeff Duntemann. Assembly Language. Programming with Linux. Step by Step THIRD EDITION

Join the p2p.wrox.com. Wrox Programmer to Programmer. Beginning. Python. Using Python 2.6 and Python 3.1. James Payne

Tumblr FOR PORTABLE EDITION

TELLING STORIES A SHORT PATH TO WRITING BETTER SOFTWARE REQUIREMENTS

New. On Smith s A Tree Grows in Brooklyn. Over 300 Titles Available and 100 Million Sold. 24-hour-a-day downloads at cliffsnotes.

Arabic. DUMmIES. by Amine Bouchentouf FOR

Digital Filmmaking For Kids

11 BOOKS. Starting an Online Business. Making Everything Easier! 2nd Edition. Inside your Google AdWords gift card worth $25

SharePoint 2010 BOOKS. Microsoft. Emer McKenna Kevin Laahs Veli-Matti Vanamo. Making Everything Easier!

Home Staging. DUMmIES

Math For Real Life FOR

Learn to: Paulina Christensen, PhD Anne Fox Wendy Foster. 2nd Edition

Do s and Don ts to Protect Your Financial Life BEN STEIN

ISBN-13. Everything you need to know about the ISBN-13 transition. The Book Industry Study Group, Inc. Brought to you by.

Smart Homes. DUMmIES 3RD EDITION. by Danny Briere and Pat Hurley FOR

HYPNOTIC WRITING How to Seduce and Persuade Customers with Only Your Words JOE VITALE John Wiley & Sons, Inc.

Visual Guide to Elliott Wave Trading

Excel Microsoft. Learn to: Greg Harvey, PhD Bestselling author of Excel All-in-One For Dummies. Making Everything Easier!

Declutter Your Life How Outer Order Leads to Inner Calm

ANN HANDLEY AND C.C. CHAPMAN

Jeremy Baras

my lie MEREDITH MARAN A True Story of False Memory Best-selling author of What It s Like to Live Now and Class Dismissed

Being Agile. Your Roadmap to Successful Adoption of Agile. Mario E. Moreira

SURVEYING (VOLUME II)

SAMPLE LESSON BUY EBOOK NOW. Learn to Read Music! Buy Ebook NOW 1

The Tudors. Learn about: Tudor life and times and how they shaped the Britain of today. David Loades. Mei Trow. Making Everything Easier!

3DTV CONTENT CAPTURE, ENCODING AND TRANSMISSION

JOSHI s Process Equipment Design

What s New in Visual FoxPro 7.0

Environmental Impact of Fertilizer on Soil and Water

Teaching and the Internet: The Application of Web Apps, Networking, and Online Tech for Chemistry Education

Songwriting. Learn to: Making Everything Easier! 2nd Edition. Jim Peterik. Dave Austin. Cathy Lynn

Feng Shui. DUMmIES 2ND EDITION. by David Daniel Kennedy FOR. Foreword by His Holiness Grandmaster Professor Lin Yun

Videoblogging. DUMmIES. by Stephanie Cottrell Bryant FOR

MOB501. SAP Omnichannel Banking 8.3 SP01 PL03 Development COURSE OUTLINE. Course Version: 03 Course Duration: 4 Day(s)

Negotiation Exercises for Journal Article Publishing Contracts and Scholarly Monograph Publishing Contracts

AWWA Publishing Preliminary Questionnaire for All Proposed Acquisitions

Table of Contents. Acknowledgements About the Authors Chapter 1 Introduction... 6

Publishing with University of Manitoba Press

AP English Literature & Composition

Copyright 2016 NSTA. All rights reserved. For more information, go to TO PURCHASE THIS BOOK, please visit

Ableton Live 8 and Suite 8

Radiology for Undergraduate Finals and Foundation Years

IoT Toolbox Mobile Application User Manual

Amber, Resinite, and Fossil Resins

ML-USS. United States Symbols Mini-Lapbook. (K-5 th Grades) Designed by Cyndi Kinney of Knowledge Box Central. (C)2009 Copyright Knowledge Box Central

Luminescence Applications

MetaLib and Your Resources

Radon: Prevalence, Measurements, Health Risks and Control. Niren L. Nagda, Editor

See Education Licence B: Statutory Text and Artistic Licence for further information

Journal of Material Science and Mechanical Engineering (JMSME)

Reasonably Simple Economics

3DTV CONTENT CAPTURE, ENCODING AND TRANSMISSION

Acceptance of a paper for publication is based on the recommendations of two anonymous reviewers.

By Lawrence F. Lowery. Copyright 2013 NSTA. All rights reserved. For more information, go to

This document is a preview generated by EVS

Statistics Ii For Dummies

Warriors Magazine, LLC

Reference Release Definition for ConnMO

Clean Code.

Student Essay Booklet

AABB Trademark Usage Guidelines

How to Write Technical Reports

Introduction to Primo

Feng Shui. Learn to: Packed with up-to-date practices to bring Feng Shui into your life. 2nd Edition

Music Theory SAMPLE CHAPTERS. Kyle Morrison Lovely. For The Modern Rockin Metalhead. Write Better Songs, Right Now! B.A Music and Sound Recording

ALEPH Z39.50 Client Conformance to U.S. National Z39.50 Profile (ANSI/NISO Z ) Version and Later

Buy The Complete Version of This Book at Booklocker.com:

Epoxy Resin Chemistry II

THE ORGANIZATIONAL ALIGNMENT HANDBOOK. A Catalyst for Performance Acceleration

Device Management Requirements

3M We are Projectors! When the show must go on, 3M makes it easy:

LIBRARY. Children s Access and Use of Digital Resources. Allison Druin, Issue Editor. Published by The Johns Hopkins University Press

DM Scheduling Architecture

Firmware Update Management Object Architecture

New ILS Data Delivery Guidelines

See for options on how to legitimately share published articles.

Flue Gas Desulfurization

Spenser and the Rocks. By Lawrence F. Lowery. Copyright 2013 NSTA. All rights reserved. For more information, go to

Device Management Requirements

Publishing & Marketing

Little Book Big Profits Series

by David Siegel illustrated by Liisa Chauncy Guida

Mathematics, Computer Science and Logic - A Never Ending Story

November Ex Libris Certified Third-Party Software and Security Patch Release Notes

AUTHOR DECLARATION FORM

User s manual. Digitales TV module for NAVIGON English (United Kingdom)

KIDS INVENTING! A Handbook for Young Inventors SUSAN CASEY

What You Need to Know About Addressing GDPR Data Subject Rights in Primo

CHARLOTTE MECKLENBURG PUBLIC ACCESS CORPORATION

Comparing JTAG, SPI, and I2C

Members of Flexible Pavements of Ohio. Cliff Ursich, P.E., President & Executive Director

FTC AGL System Controller Reference Manual Part Number

Screening Loans Registration Form

Move & Store Cart CONTENTS. Assembly Instructions

How Does the. Wind Blow? By Lawrence F. Lowery. Copyright 2013 NSTA. All rights reserved. For more information, go to

Designed in Colorado, USA. Bluetooth Cable. Quick Start Guide

Congratulations and Thank You! Premium Video Ad Prior to the Video Shoot Vendor Communications and Preparations

Transcription:

Visual Basic 2008 FOR DUMmIES by Bill Sempf

Visual Basic 2008 FOR DUMmIES

Visual Basic 2008 FOR DUMmIES by Bill Sempf

Visual Basic 2008 For Dummies Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 www.wiley.com Copyright 2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. Visual Basic and Visual Studio are registered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP- RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON- TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE- ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON- TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR- THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR- MATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services, please contact our Customer Care Department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2008923124 ISBN: 978-0-470-18238-3 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1

About the Author I am Bill Sempf, and you ll notice that I don t write in third person. I have spent an inordinate amount of time in the last several years writing about, thinking about, and coding in VB.NET. I am a coauthor of Professional Visual Studio.NET, Effective Visual Studio.NET, Professional ASP.NET Web Services and Professional VB.NET (among others), and a frequent contributor to the Microsoft Developer Network, Builder.com, Hardcore Web Services, Inside Web Development Journal, and Intranet Journal. I have recently been an invited speaker for DevEssentials, the International XML Web Services Expo, and the Association of Information Technology Professionals. As a graduate of Ohio State University with a Bachelor of Science in Business Administration, Microsoft Certified Professional, Certified Internet Business Strategist, and Certified Internet Webmaster, I have developed over one hundred Web applications for startups and Fortune 500 companies alike. I began my career in 1985 by helping my father (also named Bill) manage Apple IIe systems for the local library. Since then, I have built applications for the likes of Lucent Technologies, Bank One, the State of Ohio, Nationwide Insurance, and Sears, Roebuck and Co. I specialized in data-driven Web applications of all types, both public and private. Currently, I am the Senior Technology Consultant at Products of Innovative New Technology in Grove City, Ohio, a Microsoft Certified Partner, working on a Learning Management System for OmniPath, inc. (www.omnipath.com). I can be reached at bill@pointweb.net.

Dedication This edition of the book was heavily influenced by the thousands of readers all over the world who took the time to e-mail with thoughts, questions, complaints, criticism, praise and ideas. To be honest, they are why I write. The majority of my good projects have come from people who read my books and call to collaborate. This book is dedicated to those readers. If you have taken the time to e-mail me or review the book or contact Wiley good or bad about this book series, thank you. Even if you are peeved because of a problem or error, you are helping make this a better product and that helps everyone. Despite what people often think, even with the best of editing and authoring, these books aren t perfect they are a community effort. Without that community, the books wouldn t be good or necessary. It s a self-replicating cycle, and I love it.

Author s Acknowledgments I cannot begin to thank the amazing team at Wiley who led me ever so carefully through the process of updating this book. Katie Feltman kept on me to revise the ideas I presented, and Mark Enochs saw to it that I stuck to schedule. The entire Wiley team, in fact, is the best an author could ever hope to have. I have gotten to know them well over the last several years, and I love them all. A project at Wendy s International led me to ask the most detail-oriented person I have ever met Mike Spivey to review the technical details of this edition. Jeff Simmons reviewed the original code, and did a good job, but this book is all the better for multiple sets of eyes. My army of peer reviewers from the original edition was fantastic: Theresa Alexander, Jim Andrews, David Deloveh, Rex Mahel, Greg McNamara, Rob Morgan, Blake Sparkes, and Gary Spencer. Here s a special note about my father, William E. Sempf, whose education background was of inestimable help in reviewing the early concepts for the book. Then, he let me use him as a guinea pig for Part I! What a trooper! Finally, a shout to the many Microsoft people who gave me a hand with specific questions about VB, Visual Studio, and the framework in general: Jan Shanahan and Susann Ragsdale in the Author Support Group, and Brad McCabe, Daniel Roth, Jay Roxe, and Steve Lasker, among many others, on the development teams.

Publisher s Acknowledgments We re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/. Some of the people who helped bring this book to market include the following: Acquisitions, Editorial, and Media Development Senior Project Editor: Mark Enochs Senior Acquisitions Editor: Katie Feltman Copy Editor: John Edwards Technical Editor: Mike Spivey Editorial Manager: Leah Cameron Media Development Project Manager: Laura Atkinson Editorial Assistant: Amanda Foxworth Sr. Editorial Assistant: Cherie Case Cartoons: Rich Tennant (www.the5thwave.com) Composition Services Project Coordinator: Kristie Rees Layout and Graphics: Alissa D. Ellet, Shane Johnson, Christine Williams, Erin Zeltner Proofreaders: John Greenough, Caitie Kelly Indexer: Potomac Indexing, LLC Publishing and Editorial for Technology Dummies Richard Swadley, Vice President and Executive Group Publisher Andy Cummings, Vice President and Publisher Mary Bednarek, Executive Acquisitions Director Mary C. Corder, Editorial Director Publishing for Consumer Dummies Diane Graves Steele, Vice President and Publisher Joyce Pepple, Acquisitions Director Composition Services Gerry Fahey, Vice President of Production Services Debbie Stailey, Director of Composition Services

Contents at a Glance Introduction...1 Part I: Getting to Know.NET Using Visual Basic...9 Chapter 1: Wading into Visual Basic...11 Chapter 2: Using Visual Studio 2008...23 Chapter 3: Designing Applications in VB 2008...43 Part II: Building Applications with VB 2008...59 Chapter 4: Building Windows Applications...61 Chapter 5: Building Web Applications...83 Chapter 6: Building Class Libraries...107 Chapter 7: Building Web Services...123 Chapter 8: Debugging in VB 2008...139 Part III: Making Your Programs Work...155 Chapter 9: Interpreting Strings and Things...157 Chapter 10: Making Decisions in Code...175 Chapter 11: Getting Loopy...187 Chapter 12: Reusing Code...197 Chapter 13: Making Arguments, Earning Returns...219 Part IV: Digging into the Framework...237 Chapter 14: Writing Secure Code...239 Chapter 15: Accessing Data...253 Chapter 16: Working with the File System...271 Chapter 17: Accessing the Internet...283 Chapter 18: Creating Images...297 Part V: The Part of Tens...309 Chapter 19: Ten Tips for Using the VB User Interface...311 Chapter 20: Ten Ideas for Taking Your Next Programming Step...325 Chapter 21: Ten Resources on the Internet...337 Index...343

Table of Contents Introduction...1 About This Book...2 Conventions Used in This Book...2 What You Don t Have to Read...3 Foolish Assumptions...4 How This Book Is Organized...4 Part I: Getting to Know.NET Using Visual Basic...4 Part II: Building Applications with VB 2008...5 Part III: Making Your Programs Work...5 Part IV: Digging into the Framework...5 Part V: The Part of Tens...5 Icons Used in This Book...6 Where to Go from Here...6 Part I: Getting to Know.NET Using Visual Basic...9 Chapter 1: Wading into Visual Basic............................11 Visual Basic s Role in the Framework...11 Saying Hello to VB 2008!...13 Installing Visual Studio...14 Starting a Windows Forms project...15 Adding functionality to the form with VB code...18 Running and operating your Windows form...19 Finding More Power in Visual Studio...20 Visual Studio doesn t just do Windows!...20 Visual Basic goes mobile...21 VB as your one-stop development shop...22 Chapter 2: Using Visual Studio 2008.............................23 Understanding Visual Studio Tools...23 Touring the Design View...24 Accessing controls with the Toolbox...26 Changing details with the Properties window...27 Organizing your project with the Solution Explorer...29 Accessing outside resources with the Server Explorer...30 Dynamically editing data with the Data Sources window...33 Moving a Tool Window...35