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
- The Image Control
- The Picture Box Control
- Animating Pictures
- Summary
- Q&A
- Workshop
- 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 Picture Box Control
If you applied everything you knew about the Image control to the Picture Box control, you could use the Picture Box control. The Picture Box control works almost exactly like the Image control, with these exceptions:
- The Picture Box control supports more properties, events, and methods than the Image control.
- The Picture Box control consumes more resources than the Image control and, therefore, is not as efficient.
The Picture Box control automatically clips the image if it will not fit within the Picture Box control's borders that you set when you placed the Picture Box control.
Suppose that you placed a rather large Picture Box control on the form but then loaded a graphic file image into the picture box that was much smaller, such as an icon. The Picture Box control would not resize, so the image would appear inside the Picture Box control (see Figure 18.4).
Figure 18.4 The Picture Box control doesn't always shrink to fit.
The AutoSize property, normally set to False, determines how the Image control responds to a loaded image's size. If AutoSize is False, the control doesn't resize to fit the image. If, however, you change AutoSize to True, the image control does resize to the image's measurements and doesn't clip. Therefore, the image will always shrink or expand as needed to fit the Image control's size when you set AutoSize to True.
Use the Align property to determine where on the form the Picture Box control appears. You can dock the control to any side of the Form window control using the Align property values described in Table 18.2.
Table 18.2. Possible Align property values.
| Property Value | Description |
| 0-None | The Picture Box control appears where you place it in the Form window. |
| 1-Align Top | The Picture Box control appears at the top of the Form window. |
| 2-Align Bottom | The Picture Box control appears at the bottom of the Form window. |
| 3-Align Left | The Picture Box control appears at the left of the Form window. |
| 4-Align Right | The Picture Box control appears at the right of the Form window. |
Animating Pictures | Next Section

Account Sign In
View your cart