Results 1 to 2 of 2

Thread: [VB6] ZapCtrlZ - Copy text file replacing EOF char

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    [VB6] ZapCtrlZ - Copy text file replacing EOF char

    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.
    Last edited by dilettante; Dec 25th, 2008 at 01:36 PM. Reason: Removed old version

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] ZapCtrlZ - Copy text file replacing EOF char

    Here is an improved version of the ZapCtrlZ utility.

    This one eliminates all dependencies (except of course for the VB6 runtime components). The package now includes a compiled EXE with the manifest embedded as well.

    There is no new functionality here, but it no longer requires about 500KB of VB6 OCXs that the earlier version used. The EXE can now run by itself, and with the manifest embedded is only about 60KB. This can be further reduced by compiling to p-code at some penalty in performance.


    Bonus! Among the sources you will find two reusable components:
    • ProgressBar - a simple progress bar UserControl.
    • CdlOpenSave - a Class for displaying the Open and Save CommonDialogs.

    You can drop these right into your own Projects or modify and extend them as you like. Comments are sparse but they are pretty simple and short modules.


    Remember: There is a precompiled EXE included, so those without VB6 can use this utility as well if they like.
    Last edited by dilettante; Dec 25th, 2008 at 02:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width