Home All Groups Group Topic Archive Search About

WriteFile? Creating a Shellnew .VBP

Author
20 Sep 2005 2:52 AM
Jim Carlock
Hello,

(1)
I'm looking for other suggestions in creating / writing a text file,
alternatives to Write # and Print #. Write # seems to have a
problem of enclosing things in quotes and there's an annoying
minor problem with resource files...

I'm currently researching using the WriteFile API to do the job
as well. So I'm asking for other suggestion(s) or other routes to
pursue...

The procedure to write the file that I've tested that works...

Private Sub CreateVBP(sPath As String)
  Dim iFile As Integer, sNewFile As String
  Dim s As String
  On Error Resume Next
  Call ChDir(sPath)
  'sNewFile = FixQuotes(sPath & NEW_VBP)
  sNewFile = NEW_VBP
  iFile = FreeFile()
  Open sNewFile For Output As #iFile
  s = LoadResString(1001)
  s = Replace$(s, vbLf, vbCrLf, , , vbTextCompare)
  's = Replace$(s, vbCr, vbCrLf, , , vbTextCompare)
  Print #iFile, LoadResString(1001)  'newlines are screwed up
  'Write #iFile, LoadResString(1001) 'automatically adds quotes
  Close #iFile
  On Error GoTo 0
End Sub

The resource file stores the text using 0A as the end of line
character...

(2)
I used s = Replace$(s, vbLf, vbCrLf, , , vbTextCompare)
successfully, but I'm wondering if there's a way to get vbCrLf
stored inside the resource file?

Anyways, this is pretty neat... it represents a great way to
demonstrate how to add an item to Explorer's -> New ->
context menu (ShellNew) without using the

  %systemroot%\ShellNew

folder to keep a copy of the file.

It seems to currently work quite well and spiffy and I've kept
it quite simple... If there's some interest...

Jim Carlock
Please post replies to the newsgroup.

Author
20 Sep 2005 3:41 AM
Someone
Add ";" at the end of Print to prevent it from adding a new line:

Print #iFile, LoadResString(1001);

Try this also:

Debug.Print "Hello";
Debug.Print "There"

This prints:

HelloThere

You could use Put statement as an alternative.


Show quoteHide quote
"Jim Carlock" <anonymous@localhost> wrote in message
news:uSDet5YvFHA.1032@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> (1)
> I'm looking for other suggestions in creating / writing a text file,
> alternatives to Write # and Print #. Write # seems to have a
> problem of enclosing things in quotes and there's an annoying
> minor problem with resource files...
>
> I'm currently researching using the WriteFile API to do the job
> as well. So I'm asking for other suggestion(s) or other routes to
> pursue...
>
> The procedure to write the file that I've tested that works...
>
> Private Sub CreateVBP(sPath As String)
>  Dim iFile As Integer, sNewFile As String
>  Dim s As String
>  On Error Resume Next
>  Call ChDir(sPath)
>  'sNewFile = FixQuotes(sPath & NEW_VBP)
>  sNewFile = NEW_VBP
>  iFile = FreeFile()
>  Open sNewFile For Output As #iFile
>  s = LoadResString(1001)
>  s = Replace$(s, vbLf, vbCrLf, , , vbTextCompare)
>  's = Replace$(s, vbCr, vbCrLf, , , vbTextCompare)
>  Print #iFile, LoadResString(1001)  'newlines are screwed up
>  'Write #iFile, LoadResString(1001) 'automatically adds quotes
>  Close #iFile
>  On Error GoTo 0
> End Sub
>
> The resource file stores the text using 0A as the end of line
> character...
>
> (2)
> I used s = Replace$(s, vbLf, vbCrLf, , , vbTextCompare)
> successfully, but I'm wondering if there's a way to get vbCrLf
> stored inside the resource file?
>
> Anyways, this is pretty neat... it represents a great way to
> demonstrate how to add an item to Explorer's -> New ->
> context menu (ShellNew) without using the
>
>  %systemroot%\ShellNew
>
> folder to keep a copy of the file.
>
> It seems to currently work quite well and spiffy and I've kept
> it quite simple... If there's some interest...
>
> Jim Carlock
> Please post replies to the newsgroup.
>
>