Paul Lomax - VB and VBA in a Nutshell.pdf

(4611 KB) Pobierz
15487727 UNPDF
VB &VBA
IN A NUTSHELL
The Language
15487727.003.png 15487727.004.png
 
VB &VBA
Paul Lomax
Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
IN A NUTSHELL
The Language
15487727.005.png 15487727.001.png
VB & VBA in a Nutshell: The Language
by Paul Lomax
Copyright © 1998 O’Reilly & Associates, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472.
Editor: Ron Petrusha
Production Editor: Mary Anne Weeks Mayo
Printing History:
October 1998:
First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are
registered trademarks of O’Reilly & Associates, Inc. The association of the image of
a Newfoundland dog and the topic of VB & VBA is a trademark of O’Reilly &
Associates, Inc.
IntelliSense, Microsoft, MS-DOS, PowerPoint, Visual Basic, Visual C++, Win32,
Windows, and Windows NT are registered trademarks, and ActiveX, Outlook, and
Visual Studio are trademarks of Microsoft Corporation. Visio is a registered
trademark of Visio Corporation. Many of the designations used by manufacturers and
sellers to distinguish their products are claimed as trademarks. Where those
designations appear in this book, and O’Reilly & Associates, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher
assumes no responsibility for errors or omissions, or for damages resulting from the
use of the information contained herein.
This book is printed on acid-free paper with 85% recycled content, 15% post-
consumer waste. O’Reilly & Associates is committed to using paper with the highest
recycled content available consistent with high quality.
ISBN: 1-56592-358-8
[4/99]
15487727.002.png
Table of Contents
Preface ..................................................................................................... vii
Part I: The Basics
Chapter 1—Introduction .................................................................... 3
What Is VBA? .......................................................................................... 3
A Brief History of VBA ........................................................................... 6
What Can You Do with VBA? ................................................................ 7
Object Models: The Power of Programming with VBA ....................... 8
Chapter 2—Program Structure ..................................................... 11
Getting a VB Program to Run .............................................................. 12
The Structure of a VB Program ........................................................... 19
Ending Your VB Program .................................................................... 23
Chapter 3—VBA Variables and Data Types ............................. 26
Visual Basic Data Types ....................................................................... 26
Type Conversion .................................................................................. 31
The Variant ........................................................................................... 33
Declaring Variables and Constants ...................................................... 37
Array Variables ..................................................................................... 39
User-Defined Types ............................................................................. 45
Variable Scope and Lifetime ................................................................ 46
Object Variables and Binding .............................................................. 47
Passing Parameters ............................................................................... 50
Intrinsic Constants ................................................................................ 53
v
VB & VBA in a Nutshell: The Language, eMatter Edition
Copyright © 2000 O’Reilly & Associates, Inc. All rights reserved.
 
Zgłoś jeśli naruszono regulamin