Programming In Visual Basic 2010

3y ago
109 Views
10 Downloads
212.41 KB
15 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Aliana Wahl
Transcription

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationProgramming in Visual Basic 2010This book is an introduction to programming using Microsoft’s Visual Basic .NET 2010. It isintended for novice programmers with little or no programming experience or no experiencewith Visual Basic. The text emphasizes programming logic and good programming techniqueswith generous explanations of programming concepts written from a nontechnical point ofview. It stresses input, processing, and output and sequence, selection, and repetition incode development. File input and output (I/O) and arrays are included. Later chaptersintroduce objects, event programming, and databases. By taking a slow and steady approachto programming ideas, this book builds new concepts from what the reader has alreadylearned. VB tips and quips inject both humor and insight.The book includes numerous programming examples and exercises, case studies, tutorials,and “Fixing a Program” sections for an in-depth look at programming problems and tools.Quizzes and review questions throughout each chapter get students to think about thematerials and how to use them. Each chapter has a summary and glossary for extra review.The accompanying web site has code downloads, I/O, and database files from small, simplefiles to large files with thousands of records, flowcharts, deskchecks, and audits to aid withprogram design, coding, and debugging, PowerPoint files for every chapter, and hundreds ofideas for programs and projects.Dr. Jim McKeown has spent more than 20 years at Dakota State University, where he isan Assistant Professor. He currently teaches programming, computer hardware, softwaretesting, and computer applications. He received a master’s degree in computer educationfrom Columbia University and holds a Ph.D. in instructional design from the University ofIowa. He has contributed several articles to the Journal for Computing in Small Colleges as wellas various other publications. in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationProgramming in VisualBasic 2010The Very Beginner’s GuideJim McKeownDakota State University in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationcambridge university pressCambridge, New York, Melbourne, Madrid, Cape Town, Singapore,São Paulo, Delhi, Dubai, TokyoCambridge University Press32 Avenue of the Americas, New York, NY 10013-2473, USAwww.cambridge.orgInformation on this title: www.cambridge.org/9780521721110 c Jim McKeown 2010This publication is in copyright. Subject to statutory exceptionand to the provisions of relevant collective licensing agreements,no reproduction of any part may take place without the writtenpermission of Cambridge University Press.First published 2010Printed in the United States of AmericaA catalog record for this publication is available from the British Library.Library of Congress Cataloging in Publication dataMcKeown, James S.Programming in Visual Basic 2010 : the very beginner’s guide / James S. McKeown.p. cm.Includes bibliographical references and index.ISBN 978-0-521-89653-5 – ISBN 978-0-521-72111-0 (pbk.)1. Microsoft Visual BASIC. 2. BASIC (Computer program language) 3. Microsoft .NET. I. Title.QA76.73.B3M39723 2010006.7 882–dc222010000054ISBNISBN978-0-521-89653-5 Hardback978-0-521-72111-0 PaperbackAdditional resources for this publication asp?isbn 9780521721110Cambridge University Press has no responsibility for the persistence oraccuracy of URLs for external or third-party Internet Web sites referred to inthis publication and does not guarantee that any content on such Web sites is,or will remain, accurate or appropriate. in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationQuick, who won the Academy Award for Best Screenplay last year? Who won aGrammy last year? Who pitched the last game of the World Series? How often dothe rich and famous make headlines for their good work, not their misdeeds? Thesepeople don’t impact your life so why is society obsessed them? And you certainlydon’t want to emulate many of them. Look around and find the ones that do impactyour life and pay attention to them.Thank you to the reviewers. Without their hard and sometimes thankless work,this book wouldn’t be nearly as good. I especially want to thank Rudy McDaniel forhis keen eye and suggestions.Thank you to Mrs. Heneghen, my first grade teacher, who taught me how to readand write and do arithmetic. She was a wonderful lady. Thank you to Mrs. Short.She instilled in me a love of learning I carry to this day. She’s still my neighbor andI’ve never been able to turn her down when she’s asked for a favor. Mrs. Pratt taughtme multiplication and division, Mrs. Moulton taught me science, and Mrs. Stuefenfirst taught me geography. I still love doing math in my head, studying science,and poring over maps. Miss Haggerty – there wasn’t a boy in the sixth grade thatwasn’t in love with her. I admired and respected Mr. Skovlund. Mr. Tordoff taughtme typing. I still use it every day, but he taught his best lessons with a whistle inhis hand. Mrs. Hefling was my English and speech teacher. I can make my livingthrough writing and speaking because of her. Mr. Magnus taught me algebra andphysics and always had time to answer questions. He was a good man. Mr. Vincentwas my history teacher and coach. His quiet dignity touched students for nearlyforty years. He made me a better person. Dr. Jerry Sweeney was my college advisor.He saw something in this skinny farm boy. Thank you to Anne Vollmer, NancyCunniff, and Howard Budin in grad school. Thank you to Dr. Jim Maxey. He wasa vice president at ACT but still had time to help me with my dissertation. Theseteachers made a difference in my life and I’ll never forget that.To Delores. See? Being a computer geek finally paid off. Now, I can start workingon the movie.Jim McKeownApril 3, 2009 in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationBrief Table of Contents12Fundamentals of Design and Programming – Startingfrom Scratch1Variables and Constants – A Place for Everythingand Everything in Its Place363Writing Programs – First You Walk, Then You Run684Writing Programs II – More Controls and New Logic1055Using If and Case – Decisions, Decisions, Decisions1446Loops – Once Is Not Enough1847Procedures and Functions – Divide and Conquer2248Writing Programs III – Tying It All Together, So Far2589File I/O – Files and Records and Fields, Oh My!31510Arrays and Structures – Organizing Data36711Events and More Controls – Tips and Tricks for Programming42912Objects and Classes – Objects Are in a Class By Themselves47513Graphics – The Visual (and Audio) Side of Visual Basic51514LINQ to SQL – The World Runs on Databases57115Crystal Reports – Tying Databases to Output601Appendicesvii in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationTable of ContentsPreface123page xvFundamentals of Design and Programming – Startingfrom Scratch1What Is Programming?Basic TasksBasic ProceduresFollowing DirectionsInterface/Instructions – The Human/Computer ConnectionsWhat Is a Program?Your First Program – College TuitionVB Variables and Constants – A Place for Everythingand Everything in Its Place36Computer Memory: Location, Location, LocationDeclarations, Input, Processing, Output – No Program Should BeWithout ThemSummaryReviewTermsKeywords36Writing Programs – First You Walk, Then You Run68Following IPO684761616263viii in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationixTable of ContentsCommenting Your CodeFormatting Your OutputErrors in Your ProgramDebugging PracticeControlling Your ControlsData Type ConversionJim Soxx Sports Sales ProgramOpen and RunFixing a Program – Van Nilla’s Ice Cream StandOn Your OwnSummaryReviewTermsKeywords4Writing Programs II – More Controls and New LogicVariable ScopeCounters and AccumulatorsMore Data TypesMethodsThe Load EventMore ControlsControlling StringsTying It All TogetherFixing a ProgramOn Your OwnSummaryReviewTermsKeywords5Using If and Case – Decisions, Decisions, DecisionsWhat Are Decision Structures?If . . . Then . . . Else StructuresFlowchart UpdateDeskcheckPotential ProblemsData ValidationStacked If StructuresElseIf in this web service Cambridge University 6161161www.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxTable of ContentsGuessing Game Case StudyCase StructuresA Roll of the Dice Case StudyTying It All TogetherOn Your OwnSummaryReviewTermsKeywords6Loops – Once Is Not EnoughWhat Are Loops?For . . . Next LoopsDo While LoopsDo Loop WhileDo Until LoopsDo Loop UntilLoop QuestionsInfinite LoopsNested LoopsChr and Asc CommandsA Little Fun With GraphicsTying It All TogetherPotential ProblemsFixing a ProgramOn Your OwnSummaryReviewTermsKeywords7Procedures and Functions – Divide and ConquerWhy Use Procedures?Flowcharting ProceduresPotential ProblemsFunctionsFlowcharting FunctionsPotential ProblemsNew Controls – Menus and TimersTying It All TogetherFixing a Program in this web service Cambridge University 2232233239240241245251www.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxiTable of ContentsOn Your OwnSummaryReviewTermsKeywords8Writing Programs III – Tying It All Together, So FarRadioButtonsCheckBoxesPotential ProblemsListBoxesComboBoxesCheckedListBoxesTab Controls, ScrollBars, and TrackBarsMultiple FormsControlling StringsMaskedTextBoxPizza Program FinishedTying It All TogetherPotential ProblemsOn Your OwnSummaryReviewTermsKeywords9File I/O – Files and Records and Fields, Oh My!The Basics of File Input and OutputSequential File AccessFile OutputDialog BoxesTry-Catch BlocksIntro to NamespacesControl Break ProgrammingMinor Control Break ProcessingUpdating FilesMerging FilesFixing a ProgramOn Your OwnSummaryReview in this web service Cambridge University 4340347350353356357357www.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxiiTable of ContentsTermsKeywords10358360Arrays and Structures – Organizing Data367Arrays – Order by the NumbersUsing an ArrayArrays and Loops – Hand in HandLoading an Array From a FileSearching an ArraySorting an ArrayTwo-Dimensional ArraysStudent Grade Program Case StudyStructuresOn Your 06411415422422422423424Events and More Controls – Tips and Tricks for ProgrammingNew EventsMouse EventsPotential ProblemsPotential ProblemsNew ControlsVariable ScopeGlobalsOverloadingEvent HandlersPotential ProblemsFixing a ProgramOn Your 53454457461462464464465466467Objects and Classes – Objects Are in a Class By ThemselvesBuilt-in Objects in this web service Cambridge University Press429475475www.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxiiiTable of ContentsCreating Classes of Your OwnUsing ClassesStudent Grade ClassPotential ProblemsEmployee Pay ClassInheritancePotential ProblemsWhy Use Classes?Fixing a ProgramOn Your OwnSummaryReviewTermsKeywords13Graphics – The Visual (and Audio) Side of Visual BasicGraphic BasicsDrawingImagesPotential ProblemsSimple Paint TutorialSoundWindows Media PlayerCreating ChartsPotential ProblemsFixing a ProgramOn Your OwnSummaryReviewTermsKeywords14LINQ to SQL – The World Runs on DatabasesBackgroundConnecting to a Database TutorialWages TutorialPotential ProblemsCustomer QueriesPotential ProblemsOn Your Own in this web service Cambridge University 1572581586587592593www.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxivTable of ystal Reports – Tying Databases to Output601Crystal Reports TutorialCreating a Report Using the Report WizardMailing LabelsPotential ProblemsOn Your 626626Appendix A American Standard Code for Information Interchange(ASCII) TableAppendix B Flowchart TableAppendix C My ApplicationAppendix D Customizing Your VB EnvironmentAppendix E Using HelpAppendix F Using DebugAppendix G Structured Query Language (SQL) BasicsAppendix H Answers to Self-Check QuestionsAppendix I Control and Variable Naming ConventionsIndex631638641643646650657661679681 in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationPrefaceWho Should Use This Book?This book is written for the newbie. It’s not for those who already know programming. If you know the basics of the computer, like word processing, spreadsheets,email, and surfing, then you’re ready to go.What’s Included?This book covers the basics, like variable and assignment statements. It explainsprogramming sequence, selection, and repetition structures – fundamentals tothe design of any good program. It explains controls and their uses, the basictools for designing your interface. Procedures and functions are covered, whichare the basic building blocks of larger programs. File input and output (I/O)is introduced. Good programs run on data and I/O is how data get into andout of the computer. From there, arrays are introduced and used to implementmore complicated programming logic including control breaks, sorting, andsearching. Events make things happen in a program and one chapter is dedicatedto events, including drag and drop. Objects are introduced and an understandingof them is crucial for successful developers. For a little fun, there’s a chapteron graphics and sound, but you’ll need a good foundation in programmingsequence, logic, and repetition to get the most from it. The world runs ondatabases and the last two chapters cover the basics of databases, including anintroduction to LINQ to SQL and Crystal Reports. LINQ connects programs todatabases. SQL (Structured Query Language) is designed to find, update, andreport data, and Crystal Reports is designed for data presentation.Why Use Visual Basic?Visual Basic is just one of dozens of programming languages, but it’s one of thebest and most successful. It’s one of the most popular languages in the world.It’s popular with business and in education. It’s object-oriented and can doalmost anything. Visual Basic is simple, the commands are straightforward, andxv in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxviPrefacethe basics are easy to grasp. With it you can write and run a program on yourfirst day. Once you have the fundamentals, you can write programs of your owndesign. It’s powerful – powerful enough to take on almost any developmentproject. Programs written in earlier versions of Visual Basic will almost alwaysconvert and run in the latest version.What Do You Need?Visual Basic comes in several flavors, from the free Express Edition available asa download from Microsoft to the Professional version that’s a part of VisualStudio. It must be installed on your computer and you must know how to startit, navigate through the folders on your system, open and save files, and, ingeneral, use a computer.You’ll also want a place to make backups. A Flash drive works well, but almostany storage drive will do. Take some time to organize your files and folders – Irecommend saving them by chapter – and spend a little extra time when namingthem. You’ll be glad you did when you go looking for that program you wrotea couple of months ago – you know, the one that used loops to calculate anddisplay interest earnings.Any Advice?You must write programs to get good at programming. You won’t learn VisualBasic by reading the text and running the sample programs. You learn by doing.Write programs. Try things. Test things. Sometimes there’s a best way or oneright way to write your code, but usually there’s more than one way to get thingsto work. Try things. Play “What if . . . ?” Nearly every chapter has a “Fixing aProgram” section or two where a program has bugs that need fixing. These willhelp you understand the good and the bad in a program. “Potential Problems”sections outline common mistakes and ways to avoid them. “Open and Run”sections have sample programs and demonstrations to help with the code andcontrols. “On Your Own” provides ideas for programs to write on your own.Each chapter has several “VB Quiz” questions. Most of them are designedto make you think or to stretch your understanding. The answers for these areat the end of every chapter. There are self-check questions at the end of everychapter, too. The answers are included in Appendix H.What to Look ForPay attention to the names used in the book. I grew up with cartoon charactersand Bond movies and I’m always looking for a good name. The VB “Quips” and“Tips” inject a little humor and a little insight. A little fun never hurt. in this web service Cambridge University Presswww.cambridge.org

Cambridge University Press978-0-521-89653-5 - Programming in Visual Basic 2010: The Very Beginner’s GuideJim McKeownFrontmatterMore informationxviiPrefaceOnline ResourcesCambridge University Press has a website with student and instructor materials. Check it out at p?isbn 9780521721110. in this web service Cambridge University Presswww.cambridge.org

Programming in Visual Basic 2010 This book is an introduction to programming using Microsoft’s Visual Basic .NET 2010. It is intended for novice programmers with little or no programming experience or no experience

Related Documents:

Visual Basic is a third-generation event-driven programming language first released by Microsoft in 1991. The versions of visual basic in shown below: The final version of the classic Visual Basic was Visual Basic 6. Visual Basic 6 is a user-friendly programming language designed for beginners. In 2002, Microsoft released Visual Basic.NET (VB .

Visual Basic - Chapter 2 Mohammad Shokoohi * Adopted from An Introduction to Programming Using Visual Basic 2010, Schneider. 2 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events. 3 2.1 An Introduction to

What Visual Basic is not H Visual Basic is not, a powerful programming language that enables you to do anything you want. H Visual Basic is not, elegant or fast. H Visual Basic is not, a replacement for C. H Visual Basic is not, anything like any other programming language you have ever used.

Visual Basic 6.0 versus Other Versions of Visual Basic The original Visual Basic for DOS and Visual Basic F or Windows were introduced in 1991. Visual Basic 3.0 (a vast improvement over previous versions) was released in 1993. Visual Basic 4.0 released in late 1995 (added 32 bit application support).

Programming Visual Basic .NET Dave Grundgeiger Publisher: O'Reilly First Edition January 2002 ISBN: 0-596-00093-6, 464 pages Published just in time for the first release of Visual Basic Studio .NET, Programming Visual Basic .NET is a programmer's complete guide to Visual Basic .NET.

BASIC, such as Microsoft QBASIC, QUICKBASIC, GWBASIC ,IBM BASICA and so on. VISUAL BASIC is a VISUAL and events driven Programming Language.These are the main divergence from the old BASIC. In BASIC, programming is done in a text-only environment and the prgram is executed sequentially. In VISUAL BASIC, programming is done in a graphical .

Visual Basic 8.0 o Visual Basic 2005, nato nel 2005, è stato implementato sul .NET Framework 2.0. Non si usa più la keyword .NET nel nome, in quanto da questo momento sarà sottointeso che Visual Basic è basato sul .NET Framework. Visual Basic 9.0 o Visual Basic 2008, nato nel 2008, è stato implementato sul .NET Framework 3.5.

can distort the roof of a cone roof tank can exceed the design pressure of the tank maximum rateofflowinoroutrate of flow, in or out atmospheric or temperature changes size vent per API 2000 or approved standard min 1 ¼ in. (32 mm) or largest connection.