#### Archived

This topic is now archived and is closed to further replies.

# Weird VB file output

## Recommended Posts

I''m using VB to write a small tool to convert an text file to HTML. First thing I tried was to write all the HTML tags before the body to the file. But when I write them they are displayed like this:

"
<HTML>
"
"
<TITLE>
"
"

This is the code that I use:

OutPutFileNumber = FreeFile
Open txtOutPut.Text For Output As #OutputFileNumber
Write #OutputFileNumber, "<HTML>"
Write #OutputFileNumber, "<TITLE>"
Write #OutputFileNumber, "MSN to HTML"
Write #OutputFileNumber, "</TITLE>"
Write #OutputFileNumber, "<BODY>"

What is wrong with my code? Sand Hawk ---------------- -Earth is 98% full. Please delete anybody you can.

##### Share on other sites
Try Print #OutputFile instead of Write #OutputFile

##### Share on other sites
Nope, it still displays the "" and the end of each write action.

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.

##### Share on other sites
I''m quite sure that

Print #Filenumber, "Blah"

should work just fine. Since I use it a lot. But if you insist, then open the file in binary mode and work from there. Create a temporary string:

Dim TempString As String

And write a line like this:

TempString = MyLine & vbNewLine
Put FileNumber, , TempString

You *might* need to include the second parameter for Put the first time you write a line, it specifies the position in the file, which will need to be 1. Leaving it blank will write at the "current" position.

Trying is the first step towards failure.

##### Share on other sites
Doesn''t work. But if I open the file as binary I suppose it''s not going to be an text file wich my Browser can open. That''s the thing I want to do.

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.

##### Share on other sites
changing the "Write" to "Print" in your code will work, i''ve been doing this for years...

##### Share on other sites
The code i used in VB 5.0

      OutputFileNumber = FreeFile  Open App.Path + "\txtOutPut.Txt" For Output As #OutputFileNumber        Print #OutputFileNumber, "<HTML>"        Print #OutputFileNumber, "<HEAD>"        Print #OutputFileNumber, "<TITLE>"        Print #OutputFileNumber, "MSN to HTML"        Print #OutputFileNumber, "</TITLE>"        Print #OutputFileNumber, "</HEAD>"        Print #OutputFileNumber, "<BODY>"  Close #OutputFileNumber

The result I get:

  <HTML><HEAD><TITLE>MSN to HTML</TITLE></HEAD><BODY>

Are you sure it doesn't work ?

[edited by - misterX on July 16, 2002 7:47:10 PM]

##### Share on other sites
quote:

But if I open the file as binary I suppose it''s not going to be an text file wich my Browser can open

Why do you suppose that?

Trying is the first step towards failure.

• ### Forum Statistics

• Total Topics
628373
• Total Posts
2982306

• 10
• 9
• 13
• 24
• 11