Jump to content
  • Advertisement

Archived

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

Sand_Hawk

Weird VB file output

This topic is 5996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Guest Anonymous Poster
Try Print #OutputFile instead of Write #OutputFile

Share this post


Link to post
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 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
changing the "Write" to "Print" in your code will work, i''ve been doing this for years...

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
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!