Vba Basics
Autor: Tim • March 8, 2018 • 1,542 Words (7 Pages) • 521 Views
...
Those who understand binary and those who don't.
---------------------------------------------------------------
- Single
□ Negative values between ‐3.402823 x 1038 and ‐1.401298 x 10‐45
- Positive values between 1.401298 x 10‐45 and 3.402823 x 1038
- Double
- Negative values between
‐1.79769313486232 x 10308 and ‐4.94065645841247 x 10‐324.
- Positive values between
4.94065645841247 x 10‐324 and 1.79769313486232 x 10308.
- Will have rounded values for some expressions such as 1/3
-
---------------------------------------------------------------
- Currency (8 bytes)
- 15 digits to the left of the decimal, 4 to the right
□ In the range of ‐922,337,203,685,477.5808 to 922,337,203,685,477.5807
- Decimal (12 bytes)
- Can have up to 28 decimal places
- Is a subtype of variant
- Use CDec to convert to decimal
-
---------------------------------------------------------------
- Contains both date and time
- Stored internally as an 8‐byte floating‐point value
- The integer portion stores the number of days since December 30, 1899
- The decimal portion stores the number of seconds since midnight
▪ The default value is 12/30/1899 00:00:00
- Date literals are assigned using # as a delimiter (#m/d/y h:m:s#)
- Integer values can be added or subtracted to modify the day
-
---------------------------------------------------------------
- System or User‐defined collections of constants
- Internal data type is long
- Three categories:
- Sequential
- Assigned
- Composite (Bitwise)
-
---------------------------------------------------------------
- There are 4 types of ‘objects’
- The ‘object’ data type
- Contains a reference to an object
- Used for ‘late binding’
- No IntelliSense available
- Errors cannot be discovered until runtime
- An instantiated class from the object model
- Use Class Modules for creating user‐defined objects
- Can implement custom properties, events and methods
- Must be instantiated before use
- UserForms for custom dialogs
-
---------------------------------------------------------------
- A user‐defined grouping of other types
- Sometimes called a Structure in other languages
- Often used in Windows API calls
- VBA version must be created to use this type of call
- Easier to use than a Class Module
- Everything is directly addressable (no properties)
- Simple declaration to use – no instantiation
- No data protection, validation or events
-
---------------------------------------------------------------
- ErrObject (Err)
- Collection
- Global
-
---------------------------------------------------------------
- Contains data about the last error
- Can be programmatically invoked using Err.Raise
- Can be cleared by using Err.Clear or any form of On Error Resume
-
---------------------------------------------------------------
- Can be thought of as an ‘object’ version of an array
- Uses properties and methods to add/remove/locate items
- Can store simple types or objects
- Many global objects are Collections
-
---------------------------------------------------------------
- Provides the global UserForms collection
- Contains references to all loaded UserForms
- Also provides methods for loading and unloading UserForms
-
---------------------------------------------------------------
- Assignment ( = )
- x = y + z
- Set wks = ActiveSheet
- Concatenation ( & )
- FullName
...