Data Format Objects (VB6)

Library to Reference

Microsoft Data Formatting Object Library (../ SYSTEM32/MSSTDFMT.DLL)

Description

The Data Format objects can be used only in conjunction with the Data Binding objects, although their use isn't mandatory. They allow you to perform complex formatting operations with a minimum of code. For example, formatting null data or mapping a data field to a checkbox are common operations you had to code manually in almost all database applications. Now these operations can be handled with just a few lines of code.

The object model, which is shown in Figure 7.3, consists of a collection object, a format object, and a value object. For most applications, you want to create a formats collection object to hold the various format objects you use in the application, but you can also simply create a format object without using the collection. The value object isn't createable and is available only when it's passed to the format object's Format or Unformat events.

Figure 7.3. The Data Format object model

When you bind a data source to a control using the bindings collection, you can specify a Format object to bind with them. As data is read from the source, it's formatted and displayed automatically. When data is read from the control and written back to the data source, it's unformatted automatically. For complex formatting operations, you can use the ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.