Microsoft Office Tutorials and References
In Depth Information
5.4.6 Date Data Type
test/
another test/
Variable-length string variables are used much more often than fixed-length strings, although the
latter have some very specific and important uses (which we will not go into in this topic).
5.4.6 Date Data Type
Variables of the Date data type require 8 bytes of storage and are actually stored as decimal
(floating-point) numbers that represent dates ranging from January 1, 100 to December 31, 9999
(no year 2000 problem here) and times from 0:00:00 to 23:59:59.
As discussed earlier, literal dates are enclosed within number signs, but when assigning a date to a
date variable, we can also use valid dates in string format. For example, the following are all valid
date/time assignments:
Dim dt As Date
dt = #1/2/98#
dt = "January 12, 2001"
dt = #1/1/95#
dt = #12:50:00 PM#
dt = #1/13/76 12:50:00 PM#
VBA has many functions that can manipulate dates and times. If you need to manipulate dates or
times in your programs, you should probably spend some time with the Excel VBA help file.
(Start by looking under "Date Data Type.")
5.4.7 Variant Data Type
The Variant data type provides a catch-all data type that is capable of holding data of any other
type except fixed-length string data and user-defined types. We have already noted the virtues and
vices of the Variant data type and discussed why variants should generally be avoided.
5.4.8 Excel Object Data Types
Excel VBA has a large number of additional data types that fall under the general category of
Object data type. We will see a complete list in the chapter on the Excel object model. To get the
feel for the types of objects in the Excel object model, here is a partial list of the more prominent
objects:
Chart-related objects:
Axis
ChartTitle
Legend
Series
AxisTitle
DataLabel
LegendEntry
SeriesCollection
Chart
DataTable
LegendKey
TickLabels
ChartArea
Floor
PlotArea
Walls
ChartColorFormat
Gridlines
Point
Pivot table-related objects:
PivotCache
PivotField
PivotFormula
PivotItem
PivotTable
Search JabSto ::




Custom Search