Seeking an EXPLANATION of 4 lines of Ron deBruin's code - which works very well, but I dont understand its notation

I am using code on a page of Ron deBruin's to move files into a zip folder.

Although it works very well for me, I cant understand this code that (successfully) creates a new ZipFolder, with the strName I provide (sPath )

Sub NewZip(sPath)
'Create empty Zip File
    If Len(Dir(sPath)) > 0 Then Kill sPath
    Open sPath For Output As #1    'this code
    Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
End Sub

Can someone explain the notation and how it works, please?
I write vba, but never in that notation

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Open sPath For Output As #1 - opens a file for writing, #1 is the alias
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0) - writes the data to the file
Close #1 - closes the file
Bill PrewIT / Software Engineering ConsultantCommented:
If Len(Dir(sPath)) > 0 Then Kill sPath

Uses the Dir() function to determine if the file already exists, and if it does then deletes (Kill) it.

Open sPath For Output As #1

Opens the file for writing as handle #1.

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

Prints the standard header signature for an empty PKZIP archive file.  This will later change to Chr$(80) & Chr$(75) & Chr$(3) & Chr$(4) when data is placed in the archive.

Close #1

Closes file handle #1 writing all data to disk.

You can dig deeper into any of the VBA functions and statements that are not familiar at these two references:

And a decent intro to the basic file I/O statements can be found here:

And you can learn way more info on the ZIP file format than you ever wanted to know at these (search the first for "50 4B 05 06" without the quotes):

Hope this helps.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin4Author Commented:
Thanks for a comprehensive explanation and references
Bill PrewIT / Software Engineering ConsultantCommented:
Welcome, glad that helped.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.