dilettante
Dec 24th, 2008, 06:17 PM
Every so often we stumble over a Ctrl-Z "EOF" character embedded within a text file.
These Ctrl-Z (decimal 26, hex &H1A, also known as ^Z) characters are treated as an EOF symbol by VB's traditional text I/O operations: Input#, Line Input#, etc. This is a carryover from the MSDOS days, where it was inherited from CP/M and kept for compatibility.
While one can work around this by doing binary I/O and splitting off records to process based on vbNewLine occurences, it often isn't worth the trouble. Many of the quick and dirty solutions entail sucking the whole file into memory at once and your file(s) may be huge. Other fancier techniques can be used but for most programs it just isn't worth the trouble. For that matter most of your files may be fine, but a few now and then have those embedded Ctrl-Zs in them.
ZapCtrlZ can be used to process an ANSI text file replacing each Ctrl-Z it finds with another character of your choosing. As written it will let you pick anything from hex 00 to 7F as the replacement symbol.
Just select an input file, an output file, and a replacement symbol - then click the Start button. It can handle text files well over 2GB in length, longer than you can read using VB I/O statements anyway!
After compiling ZapCtrlZ be sure to keep its manifest file in the same folder to enable themed controls.
These Ctrl-Z (decimal 26, hex &H1A, also known as ^Z) characters are treated as an EOF symbol by VB's traditional text I/O operations: Input#, Line Input#, etc. This is a carryover from the MSDOS days, where it was inherited from CP/M and kept for compatibility.
While one can work around this by doing binary I/O and splitting off records to process based on vbNewLine occurences, it often isn't worth the trouble. Many of the quick and dirty solutions entail sucking the whole file into memory at once and your file(s) may be huge. Other fancier techniques can be used but for most programs it just isn't worth the trouble. For that matter most of your files may be fine, but a few now and then have those embedded Ctrl-Zs in them.
ZapCtrlZ can be used to process an ANSI text file replacing each Ctrl-Z it finds with another character of your choosing. As written it will let you pick anything from hex 00 to 7F as the replacement symbol.
Just select an input file, an output file, and a replacement symbol - then click the Start button. It can handle text files well over 2GB in length, longer than you can read using VB I/O statements anyway!
After compiling ZapCtrlZ be sure to keep its manifest file in the same folder to enable themed controls.