+ Reply to Thread
Results 1 to 5 of 5

Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

  1. #1
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Kolkata, India
    MS-Off Ver
    Excel 2003/2007
    Posts
    182

    Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

    Hello Everyone,

    To create a empty ZIP folder by VBA we have to use below codes..

    Please Login or Register  to view this content.
    I would like to know what it acutually does and what is the purpose of using each Chr$() and String(18, 0).

    Thanks in advance.

    Regards
    taps

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

    Print #1 is a command that prints data to a file. The file is created or opened in a previous statement, and assigns the file number 1 to it. You didn't show us that statement, but it must be there someplace.

    I do not know why this particular sequence would create a ZIP folder.

    Chr$ (same as Chr) is a function that returns the ASCII character associated with the numeric code provided as an argument. Highlight Chr in the code then hit F1 for an explanation.

    0-31 are nonprintable codes.
    5 - ENQ (enquiry)
    6 - ACK (acknowledge)

    I have no idea how these are being interpreted in the file you are writing. Many of the unprintable ASCII codes were assigned in the teletype days to cause an action on the receiving machine. For example, 7 rings a bell. But they could be used for anything as long as the writer and reader agree on how to interpret them.

    65-90 are uppercase letters:
    80 - P
    75 - K

    The function String repeats a string the given number of times. Highlight String in the code then hit F1 for an explanation. In your case the string is the code 0 which is the ASCII code for "null". Again, I have no idea why you would need to write 18 nulls to the file.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Kolkata, India
    MS-Off Ver
    Excel 2003/2007
    Posts
    182

    Re: Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

    Dear Friend,

    Thanks for your assistance.

    Below are the few link where I got information about the Zipping files by VBA.

    http://www.excelforum.com/excel-prog...g-a-macro.html
    http://www.rondebruin.nl/windowsxpzip.htm
    http://excelexperts.com/zip-files-from-excel
    http://www.teachexcel.com/excel-help...o.php?i=379496

    Why everybody is using the code (Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)) is really unknown.
    May be above links can guide to find the answer.


    Regards
    taps
    Last edited by taps; 12-05-2012 at 11:25 AM.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

    That combination of letters, numbers and non printing characters is placed at the beginning of the file that you create so that Windows knows what type of file it is - it's a file identifier. That identifier is the generic fingerprint of an empty zip file (folder).

    If you're interested in reading why then have a look at: http://www.pkware.com/documents/casestudies/APPNOTE.TXT

    To see it in action, create an empty zip folder than open it with notepad - you'll see the text that is there is the same as you've printed. It's a little more descriptive however if you open it in an advanced text editor like NotePad++

    You'll see that any file format that is zip based, will follow the same schema PK followed by data, try opening a xlsx or docx or even ods document and you'll see this in action - you can then change the extension to .zip and browse through the contents. A file doesn't need the .zip extension to conform to the specifications
    Last edited by Kyle123; 12-05-2012 at 12:22 PM.

  5. #5
    Forum Contributor
    Join Date
    09-29-2011
    Location
    Kolkata, India
    MS-Off Ver
    Excel 2003/2007
    Posts
    182

    Re: Function of Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)

    Dear Kyle123,

    Thanks a ton for the valuable informations. It is really very very helpful.

    Regards
    taps

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1