Download... (32 kb)
One of the most annoying tasks a programmer must face is to
output files in various formats. Most of the time, these
formats are fixed lengths file formats. Many institutions
(mostly financial, medical and insurance) use a variety of
these because they rely on mainframes that have served them
well over the years.
To us, VB programmers, this means endless tinkering
with field lengths, padding, formatting, etc I finally
got sick of it and wrote a class that handles all this
and more. You simply specify the columns & their properties,
header & footer (if apply), hand me a Recordset, name of the
output file and voila - the class does the rest.
In all, the class provides the following features:
- Right or Left justify of fields
- Leading zeroes
- On the fly formatting - i.e. you provide the format in the style of VB's
Format function
- Optional spaces after fields
- Event notification for output progress
- Footer/Header
- Include column headings
- Change Row separator from Carriage Return to anything you want.
- Hooks are in for VBScript to format/change each field, but not
implemented yet.
- Works off an ADO Recordset (either ClientSide or ServerSide). Event
notifications on progress are provided only for ClientSide for obvious
reasons.
Configuring the class is extremely easy. Just provide it with column information and
you are just about done:
.AddColumn "iAlign_no", 5, 0, Justify_Right, True, ""
.AddColumn "szNoteText_tx", 35, 0, Justify_Left, False, "", ""
.AddColumn "sLastUpdate_id", 16, 0, Justify_Left, False, "", ""
.AddColumn "dtLastUpdate_dt", 20, 0, Justify_Left, False, "mm/dd/yyyy hh:mm:ss", ""
.AddColumn "iConcurrency_id", 5, 0, Justify_Left, False, "", ""
Included in the download is a demo program that demonstrates the functionality, as well
as a sample Access database that I used to test the class. To start the
demo, download, start demo.vbp, then press the Run button. Enjoy.
Download... (32 kb)