Sams Teach Yourself Visual Basic 6 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Introduction
- Who Should Read This Book
- What This Book Will Do for You
- Can This Book Really Teach Visual Basic in 24 Hours?
- What You Need
- Files on the Visual Basic Distribution CD-ROM
- Conventions Used in This Book
- Enough! Time Is Ticking!
- Part I: Introducing Visual Basic
- Hour 1. Visual Basic at Work
- Hour 2.Analyzing Visual Basic Programs
- Hour 3.Controls and Properties
- Hour 4.Examining Labels, Buttons, and Text Boxes
- Part II: Coding the Details
- Hour 5.Putting Code into Visual Basic
- Hour 6.Message and Input Boxes
- Hour 7.Making Decisions
- Hour 8.Visual Basic Looping
- Part III:Putting Code to Work
- Hour 9.Combining Code and Controls
- Hour 10.List Boxes and Data Lists
- Hour 11.Additional Controls
- Hour 12.Dialog Box Basics
- Part IV:Programming with Data
- Hour 13.Modular Programming
- Hour 14.Built-In Functions Save Time
- Hour 15.Visual Basic Database Basics
- Hour 16.Printing with Visual Basic
- Part V:Sprucing Up Programs
- Hour 17.Menus and Visual Basic
- Hour 18.The Graphic Image Controls
- Hour 19.Toolbars and More Graphics
- Hour 20.Writing Correct Applications
- Part VI:Advancing Visual Basic Applications
- Hour 21.Visual Basic and ActiveX
- Hour 22.Object Basics
- Hour 23.Distributing Your Applications
- Hour 24.Online Visual Basic
- Part VII:Appendixes
- Appendix A.Operator Precedence
- Appendix B.Answers
- Appendix C.Using the CD-ROM
The System Objects
You've worked with several Visual Basic objects already. The Printer object is an object you use with a Print method to send output to the printer, as in the following statement:
Printer.Print Tab(15); "Company Balance Sheet"
In addition, you've seen the Debug object when printing to the Immediate window like this:
Debug.Print "intVar is "; intVar
In both cases, the object represents an item outside your application's scope. The printer and the Immediate window are not your application's; therefore, Visual Basic uses objects to represent them. The Printer object doesn't reference any particular printer; rather, the Printer object references the current Windows printer. The Debug object represents the Immediate window.
A system object is an object defined by Visual Basic that lies outside your program's immediate scope.
The Printer and the Debug objects are system objects predefined by the Visual Basic system. Although a command button on your form is an object, the command button isn't a system object because the object didn't really exist before you placed the command button on the form—only its pattern existed on the Toolbox window.
Table 22.1 lists all the predefined system objects your applications can work with.
Table 22.1. The system objects and their methods.
| Object | Description | Methods |
| App | Your current application | The EXEName method returns the application's filename. Path returns the application's path. Title returns the primary startup form's title bar text. Previnstance returns True or False to indicate whether another instance (copy) of the application is currently running. |
| ClipBoard | The Windows Clipboard | The method Clear erases the Clipboard. GetData returns the graphic image stored on the Clipboard. GetFormat returns the format of the Clipboard object. GetText returns the text on the Clipboard. SetData copies a graphic image to the Clipboard. SetText copies text to the Clipboard. |
| Debug | The Immediate window | The method Print copies information, at runtime, to the Immediate window (only possible in Visual Basic programs you run from Visual Basic's development environment). |
| Printer | The system printer | Provides printer support. |
| Screen | The user's screen | FontCount returns the number of fonts the current screen supports. Fonts contains a list of all the screen's possible font names. Height returns the twip height of the screen area. MousePointer holds (or determines if you specify a new one) the shape of the mouse cursor. TwipsPerPixelX returns the number of possible horizontal twips. TwipsPerPixelY returns the number of possible vertical twips. Width returns the width, in twips, of the screen. |
Use these objects and methods to return information about the objects. For example, you could append the current application pathname to a string variable like this:
strFullName = App.Path & "\" & "Afile.dat"
Although you won't use the system objects in every application, they do come in handy when you're performing interaction with the Windows Clipboard or the screen.
Program Objects | Next Section

Account Sign In
View your cart