VB & VBA in a Nutshell: The Language

Book description

The online documentation of VB/VBA language components seems to follow the 80/20 rule: the basic facts that you need to use a language statement are provided in the documentation. But the additional 20 percent that you need to use it effectively or to apply it to special cases is conspicuously absent. To a professional VB/VBA programmer, though, this missing 20 percent of the language's documentation isn't a luxury, it's a necessity. And in VB & VBA in a Nutshell: The Language, it finally is available. The bulk of the book consists of an alphabetical reference to the statements, procedures, and functions of the VB/VBA language. Each entry has a standardized listing containing the following information:

  • Its syntax, using standard code conventions

  • Differences in the operation of the keyword in a macro environment (e.g., in Office) and in Visual Basic, if there are any

  • A list of arguments accepted by the function or procedure, if any

  • A description of the data type returned by a function

  • The finer points of a keyword's usage that are often omitted from or blurred over by the documentation

  • Tips and gotchas that include undocumented behaviors and practical applications for particular language elements -- a section particularly invaluable for diagnosing or avoiding potential programming problems

  • A brief, nonobvious example that illustrates the use of the keyword

  • Basic VBA programming concepts, such as its data types and its support for variables, constants, and arrays

  • Error handling in VBA applications

  • Object programming with VBA

  • Using VBA with particular applications. Excel and Project are utilized to show how to work with an application's integrated development environment and to take advantage of its object model Regardless of how much experience you have programming with VBA, this is the book you'll pick up time and time again both as your standard reference guide and as a tool for troubleshooting and identifying programming problems.

  • Also included in VB & VBA in a Nutshell: The Language is a brief overview of the VB/VBA language, including:

    VB & VBA in a Nutshell: The Language is the definitive reference for Visual Basic and VBA developers.

    Table of contents

    1. Copyright
    2. Preface
      1. Why Another VB Book?
      2. What's Wrong with the Online Help?
      3. Who Should Read This Book?
      4. How This Book Should Be Used
      5. How This Book Is Structured
      6. Conventions Used in This Book
      7. How to Contact Us
      8. Acknowledgments
    3. The Basics
      1. Introduction
        1. What Is VBA?
        2. A Brief History of VBA
        3. What Can You Do with VBA?
        4. Object Models: The Power of Programming with VBA
      2. Program Structure
        1. Getting a VB Program to Run
        2. The Structure of a VB Program
        3. Ending Your VB Program
      3. VBA Variables and Data Types
        1. Visual Basic Data Types
        2. Type Conversion
        3. The Variant
        4. Declaring Variables and Constants
        5. Array Variables
        6. User -Defined Types
        7. Variable Scope and Lifetime
        8. Object Variables and Binding
        9. Passing Parameters
        10. Intrinsic Constants
      4. Class Modules
        1. Properties
        2. Enumerated Constants
        3. Class Module Events
        4. Implementing Custom Class Methods
        5. Creating ActiveX Components
        6. Using ActiveX Components in a Project
      5. Automation
        1. Creating Object Model References
        2. Reading the Object Model
        3. Working with the Object Model
        4. Collection Objects
        5. Trapping an Automation Server's Events
        6. Automation Examples
        7. Automation Performance Tips
      6. Error Handling
        1. Building a Robust Application
        2. Error Handling in Procedures
        3. Error Handling in ActiveX Servers
        4. Reporting Errors
    4. Reference
      1. The Language Reference
      2. The Language Reference, Part 1: #Const Directive–Drives Collection Object (VB6)
        1. #Const Directive
        2. #If...Then...#Else Directive
        3. Abs Function
        4. AddressOf Operator
        5. AppActivate Statement
        6. Array Function
        7. Asc, AscB, AscW Functions
        8. Atn Function
        9. Beep Statement
        10. BindingCollection Object (VB6)
        11. BindingCollection.Add Method (VB6)
        12. BindingCollection.Clear Method (VB6)
        13. BindingCollection Remove.Method (VB6)
        14. Binding Object (VB6)
        15. Calendar Property
        16. Call Statement
        17. CallByName Function (VB6)
        18. CBool Function
        19. CByte Function
        20. CCur Function
        21. CDate Function
        22. CDbl Function
        23. CDec Function
        24. ChDir Statement
        25. ChDrive Statement
        26. Choose Function
        27. Chr, Chr$, ChrB, ChrB$, ChrW Functions
        28. CInt Function
        29. CLng Function
        30. Close Statement
        31. Collection Object
        32. Collection.Add Method
        33. Collection.Count Property
        34. Collection.Item Method
        35. Collection.Remove Method
        36. Command Function
        37. Const Statement
        38. Cos Function
        39. CreateObject Function
        40. CSng Function
        41. CStr Function
        42. CurDir, CurDir$ Functions
        43. CVar Function
        44. CVDate Function
        45. CVErr Function
        46. Data Binding Objects (VB6)
        47. Data Format Objects (VB6)
        48. DataBindingBehavior Property (VB6 only)
        49. DataSourceBehavior Property (VB6 only)
        50. Date, Date$ Functions
        51. Date Statement
        52. DateAdd Function
        53. DateDiff Function
        54. DatePart Function
        55. DateSerial Function
        56. DateValue Function
        57. Day Function
        58. DDB Function
        59. Debug Object
        60. Debug.Assert Method
        61. Debug.Print Method
        62. Declare Statement
        63. Def... Statement
        64. DeleteSetting Statement
        65. Dictionary Object (VB6)
        66. Dictionary.Add Method (VB6)
        67. Dictionary.CompareMode Property (VB6)
        68. Dictionary.Count Property (VB6)
        69. Dictionary.Exists Method (VB6)
        70. Dictionary.Item Property (VB6)
        71. Dictionary.Items Method (VB6)
        72. Dictionary.Key Property (VB6)
        73. Dictionary.Keys Method (VB6)
        74. Dictionary.Remove Method (VB6)
        75. Dictionary.RemoveAll Method (VB6)
        76. Dim Statement
        77. Dir, Dir$ Functions
        78. Do...Loop Statement
        79. DoEvents Function
        80. Drive Object (VB6)
        81. Drives Collection Object (VB6)
      3. The Language Reference, Part 2: End... Statement–FV Function
        1. End... Statement
        2. Enum Statement
        3. Environ, Environ$ Functions
        4. EOF Function
        5. Erase Statement
        6. Err Object
        7. Err.Clear Method
        8. Err.Description Property
        9. Err.HelpContext Property
        10. Err.HelpFile Property
        11. Err.LastDLLError Property
        12. Err.Number Property
        13. Err.Raise Method
        14. Err.Source Property
        15. Error, Error$ Functions
        16. Error Statement
        17. Event Statement
        18. Exit Statement
        19. Exp Function
        20. File Object (VB6)
        21. File.Copy Method (VB6)
        22. File.Delete Method (VB6)
        23. File.Move Method (VB6)
        24. File.OpenAsTextStream Method (VB6)
        25. File System Object Model (VB6)
        26. FileAttr Function
        27. FileCopy Statement
        28. FileDateTime Function
        29. FileLen Function
        30. Files Collection Object (VB6)
        31. FileSystemObject Object (VB6)
        32. FileSystemObject.BuildPath Method (VB6)
        33. FileSystemObject.CopyFile Method (VB6)
        34. FileSystemObject.CopyFolder Method (VB6)
        35. FileSystemObject.CreateFolder Method (VB6)
        36. FileSystemObject.CreateTextFile Method (VB6)
        37. FileSystemObject.DeleteFile Method (VB6)
        38. FileSystemObject.DeleteFolder Method (VB6)
        39. FileSystemObject.DriveExists Method (VB6)
        40. FileSystemObject.Drives Property (VB6)
        41. FileSystemObject.FileExists Method (VB6)
        42. FileSystemObject.FolderExists Method (VB6)
        43. FileSystemObject.GetAbsolutePathName Method (VB6)
        44. FileSystemObject.GetBaseName Method (VB6)
        45. FileSystemObject.GetDrive Method (VB6)
        46. FileSystemObject.GetDriveName Method (VB6)
        47. FileSystemObject.GetExtensionName Method (VB6)
        48. FileSystemObject.GetFile Method (VB6)
        49. FileSystemObject.GetFileName Method (VB6)
        50. FileSystemObject.GetFolder Method (VB6)
        51. FileSystemObject.GetParentFolderName Method (VB6)
        52. FileSystemObject.GetSpecialFolder Method (VB6)
        53. FileSystemObject.GetTempName Method (VB6)
        54. FileSystemObject.MoveFile Method (VB6)
        55. FileSystemObject.MoveFolder Method (VB6)
        56. FileSystemObject.OpenTextFile Method (VB6)
        57. Filter Function (VB6)
        58. Fix Function
        59. Folder Object (VB6)
        60. Folder.Copy Method (VB6)
        61. Folder.CreateTextFile Method (VB6)
        62. Folder.Delete Method (VB6)
        63. Folder.Move Method (VB6)
        64. Folders Collection Object (VB6)
        65. Folders.Add Method (VB6)
        66. For...Next Statement
        67. For Each...Next Statement
        68. Format, Format$ Functions
        69. FormatCurrency, FormatNumber, FormatPercent Functions (VB6)
        70. FormatDateTime Function (VB6)
        71. FreeFile Function
        72. Function Statement
        73. FV Function
      4. The Language Reference, Part 3: Get Statement–PV Function
        1. Get Statement
        2. GetAllSettings Function
        3. GetAttr Function
        4. GetAutoServerSettings Function
        5. GetObject Function
        6. GetSetting Function
        7. GoSub...Return Statement
        8. Goto Statement
        9. Hex, Hex$ Functions
        10. Hour Function
        11. If...Then...Else Statement
        12. IIf Function
        13. IMEStatus Function
        14. Implements Statement
        15. Initialize Event
        16. Input, Input$, InputB, InputB$ Functions
        17. Input # Statement
        18. InputBox Function
        19. Instancing Property (VB only)
        20. InStr, InStrB Functions
        21. InstrRev Function (VB6)
        22. Int Function
        23. IPmt Function
        24. IRR Function
        25. IsArray Function
        26. IsDate Function
        27. IsEmpty Function
        28. IsError Function
        29. IsMissing Function
        30. IsNull Function
        31. IsNumeric Function
        32. IsObject Function
        33. Join Function (VB6)
        34. Kill Statement
        35. LBound Function
        36. LCase, LCase$ Functions
        37. Left, Left$, LeftB, LeftB$ Functions
        38. Len, LenB Functions
        39. Like Operator
        40. Line Input# Statement
        41. Load Statement
        42. LoadResData Function
        43. LoadResPicture Function
        44. LoadResString Function
        45. Loc Function
        46. Lock Statement
        47. LOF Function
        48. Log Function
        49. LSet Statement
        50. LTrim, LTrim$ Functions
        51. Me Operator
        52. Mid, Mid$, MidB, MidB$ Functions
        53. Mid, MidB Statements
        54. Minute Function
        55. MIRR Function
        56. MkDir Statement
        57. Month Function
        58. MonthName Function (VB6)
        59. MsgBox Function
        60. MTSTransactionMode Property (VB6 only)
        61. Name Property
        62. Name Statement
        63. Now Function
        64. NPer Function
        65. NPV Function
        66. Oct, Oct$ Functions
        67. On Error Statement
        68. Open Statement
        69. Option Base Statement
        70. Option Compare Statement
        71. Option Explicit Statement
        72. Option Private Module Statement
        73. Persistable Property (VB6 Only)
        74. Pmt Function
        75. PPmt Function
        76. Print # Statement
        77. Printer Object and Printers Collection
        78. Private Statement
        79. Property Get Statement
        80. Property Let Statement
        81. Property Set Statement
        82. Public Statement
        83. Put Statement
        84. PV Function
      5. The Language Reference, Part 4: QBColor Function–Year Function
        1. QBColor Function
        2. RaiseEvent Statement
        3. Randomize Statement
        4. Rate Function
        5. ReDim Statement
        6. Rem Statement
        7. Replace Function (VB6)
        8. Reset Statement
        9. Resume Statement
        10. Return Statement
        11. RGB Function
        12. Right, Right$, RightB, RightB$ Functions
        13. RmDir Statement
        14. Rnd Function
        15. Round Function
        16. RSet Statement
        17. RTrim, RTrim$ Functions
        18. SaveSetting Statement
        19. Second Function
        20. Seek Function
        21. Seek Statement
        22. Select Case Statement
        23. SendKeys Statement
        24. Set Statement
        25. SetAttr Statement
        26. Sgn Function
        27. Shell Function
        28. Sin Function
        29. SLN Function
        30. Space, Space$ Functions
        31. Spc Function
        32. Split Function (VB6)
        33. Sqr Function
        34. Static Statement
        35. stdDataFormat Object (VB6)
        36. stdDataFormats Object (VB6)
        37. Stop Statement
        38. Str, Str$ Functions
        39. StrComp Function
        40. StrConv Function
        41. String, String$ Functions
        42. StrReverse Function (VB6)
        43. Sub Statement
        44. Switch Function
        45. SYD Function
        46. Tab Function
        47. Tan Function
        48. Terminate Event
        49. TextStream Object
        50. TextStream.Close Method
        51. TextStream.Read Method
        52. TextStream.ReadAll Method
        53. TextStream.ReadLine Method
        54. TextStream.Skip Method
        55. TextStream.SkipLine Method
        56. TextStream.Write Method
        57. TextStream.WriteBlankLines Method
        58. TextStream.WriteLine Method
        59. Time, Time$ Functions
        60. Time Statement
        61. Timer Function
        62. TimeSerial Function
        63. TimeValue Function
        64. Trim, Trim$ Functions
        65. Type Statement
        66. TypeName Function
        67. UBound Function
        68. UCase, UCase$ Functions
        69. Unload Statement
        70. Unlock Statement
        71. Val Function
        72. VarType Function
        73. Weekday Function
        74. WeekdayName Function (VB6)
        75. While...Wend Statement
        76. Width # Statement
        77. With Statement
        78. WithEvents Keyword
        79. Write # Statement
        80. Year Function
    5. Appendixes
      1. Language Elements by Category
        1. Collection Object
        2. Conditional Compilation
        3. Data Type Conversion Functions
        4. Data Bindings Objects (VB6 only)
        5. Date and Time Functions
        6. Dictionary Object (VB6 Only)
        7. Err Object
        8. FileSystem Objects (VB6 only)
        9. File and Folder Handling
        10. Financial Functions
        11. Formatting Functions
        12. Information Functions
        13. Interaction Functions
        14. Math Functions
        15. Programming and ActiveX Programming
        16. Printer Object
        17. Program Structure and Flow
        18. Registry Functions
        19. String Manipulation
        20. Variable Declaration
      2. Language Constants
        1. Application Window Style (VbAppWinStyle)
        2. Calendar (VBCalendar)
        3. Call Type (VB6 only)
        4. Compare Method (VbCompareMethod)
        5. Data Binding Update Mode (VB6 Only)
        6. Date Time Format Styles (VB6 Only)
        7. Day of Week (VbDayOfWeek)
        8. Drive Type (VB6 only)
        9. File Attributes (VbFileAttribute)
        10. File System Objects File Attributes (VB6 Only)
        11. First Week of Year (VbFirstWeekOfYear)
        12. IME Status (VbIMEStatus)
        13. Language Constants
        14. Log Event Type Style (LogEventTypeConstants)
        15. Log Mode Constants (VB6 only)
        16. Message Box Result (VbMsgBoxResult)
        17. Message Box Style (VbMsgBoxStyle)
        18. Special Folder Types (VB6 only)
        19. String Conversion (VbStrConv)
        20. TextStream IOMode (VB6 only)
        21. Tristate Constants (VB6 Only)
        22. Variant Type (VbVarType)
      3. Operators
        1. Arithmetic Operators
        2. String Operator
        3. Comparison Operators
        4. Logical and Bitwise Operators
        5. Operator Precedence
      4. What's New in VB6?
        1. Create DataSource and Data Consumer Classes
        2. Functions Can Return Arrays
        3. Dynamic Arrays Can Be Assigned
        4. Remote User-Defined Types
        5. New Functions
        6. Enhanced CreateObject Function
        7. New Object Models
    6. Colophon
    7. Index

    Product information

    • Title: VB & VBA in a Nutshell: The Language
    • Author(s): Paul Lomax
    • Release date: October 1998
    • Publisher(s): O'Reilly Media, Inc.
    • ISBN: 9781565923584