Book contents
- Frontmatter
- Contents
- Preface
- 1 Fundamentals of Design and Programming – Starting from Scratch
- 2 Variables and Constants – A Place for Everything and Everything in Its Place
- 3 Writing Programs – First You Walk, Then You Run
- 4 Writing Programs II – More Controls and New Logic
- 5 Using If and Case – Decisions, Decisions, Decisions
- 6 Loops – Once Is Not Enough
- 7 Procedures and Functions – Divide and Conquer
- 8 Writing Programs III – Tying It All Together, So Far
- 9 File I/O – Files and Records and Fields, Oh My!
- 10 Arrays and Structures – Organizing Data
- 11 Events and More Controls – Tips and Tricks for Programming
- 12 Objects and Classes – Objects Are in a Class By Themselves
- 13 Graphics – The Visual (and Audio) Side of Visual Basic
- 14 LINQ to SQL – The World Runs on Databases
- 15 Crystal Reports – Tying Databases to Output
- Appendices
- Index
12 - Objects and Classes – Objects Are in a Class By Themselves
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- 1 Fundamentals of Design and Programming – Starting from Scratch
- 2 Variables and Constants – A Place for Everything and Everything in Its Place
- 3 Writing Programs – First You Walk, Then You Run
- 4 Writing Programs II – More Controls and New Logic
- 5 Using If and Case – Decisions, Decisions, Decisions
- 6 Loops – Once Is Not Enough
- 7 Procedures and Functions – Divide and Conquer
- 8 Writing Programs III – Tying It All Together, So Far
- 9 File I/O – Files and Records and Fields, Oh My!
- 10 Arrays and Structures – Organizing Data
- 11 Events and More Controls – Tips and Tricks for Programming
- 12 Objects and Classes – Objects Are in a Class By Themselves
- 13 Graphics – The Visual (and Audio) Side of Visual Basic
- 14 LINQ to SQL – The World Runs on Databases
- 15 Crystal Reports – Tying Databases to Output
- Appendices
- Index
Summary
VB Quip
But what is it good for? – an engineer at the Advanced Computing Systems Division of IBM, commenting on the microchip in 1968
Think of objects as tools. Better yet, think of them as building blocks. Imagine how hard a job would be if you had to create everything from scratch every time. Say you wanted to build a table. First, you'd need to make an axe to cut down the tree. Then you'd have to make a saw to cut the wood. You'd have to make your own nails to piece together the table, but that's only after you made your own hammer so you could pound the nails. Programming is like that sometimes – OK, usually. And it was certainly that way years ago. Everything was done from scratch and very little was reusable. However, there's been some progress since then. You saw reusable code when you learned procedures and functions. Objects and classes are that way, but on a grander scale. The controls in the Toolbox are objects, each specially created for a specific task. They're tools and, without them, development would be much tougher, and a whole lot less fun. Classes are code that defines an abstract data type – it's a thing, and the developer provides a description of it and determines how it can be used. This chapter shows you how to create objects with your code and how to define and use classes.
- Type
- Chapter
- Information
- Programming in Visual Basic 2010The Very Beginner's Guide, pp. 475 - 514Publisher: Cambridge University PressPrint publication year: 2010