Export Fixed Length Files

Applies To

OS:
VB:
NT, 9x, 2000
5, 6

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:

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)