Archived

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

Sand_Hawk

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>
"
"
<HEAD>
  
This is the code that I use:
  
OutPutFileNumber = FreeFile
Open txtOutPut.Text For Output As #OutputFileNumber
Write #OutputFileNumber, "<HTML>"
Write #OutputFileNumber, "<HEAD>"
Write #OutputFileNumber, "<TITLE>"
Write #OutputFileNumber, "MSN to HTML"
Write #OutputFileNumber, "</TITLE>"
Write #OutputFileNumber, "</HEAD>"
Write #OutputFileNumber, "<BODY>"
  
What is wrong with my code? Sand Hawk ---------------- -Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites