Open/save text

How can a open/save a text file with out going through a rich text box. I want plane ascii text. The Rich text box adds all kinds of extra formating that i don't want. (Vb4)
hessAsked:
Who is Participating?
 
clifABBConnect With a Mentor Commented:
Here is the answer:
hFile = FreeFile
Open "TESTFILE" For Output As #hFile
Print #hFile, Text1.Text
Close hFile

Glad I could help.
0
 
hessAuthor Commented:
Edited text of question
0
 
clifABBCommented:
To write a textfile:

hFile = FreeFile
Open "TESTFILE" For Output As #hFile
Print #hFile, sOutString
Close hFile

To read a text file:

hFile = FreeFile
Open "TESTFILE" For Input As #hFile
Input #hFile, sInString
Close hFile


0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
hessAuthor Commented:
I needds to read more than one line
0
 
hessAuthor Commented:
The answer proposed by clifABB only reads only line of text
0
 
hessAuthor Commented:
The answer proposed by clifABB only reads only line of text
0
 
electrickCommented:
I've had good luck using a ListBox to input text files.
Goes something like this.

Dim InputData
Open "MYFILE" For Input As #1      ' Open file for input.
Do While Not EOF(1)      ' Check for end of file.
      Line Input #1, InputData      ' Read line of data.
      List1.AddItem InputData
Loop
Close #1      ' Close file.
0
 
clifABBCommented:
If you need to read more than one line, then put the code in a loop:
sFullString = ""
hFile = FreeFile
Open "TESTFILE" For Input As #hFile
Do Until EOF(hFile)
  Input #hFile, sInString
  sFullString = sFullString & sInString
Loop
Close hFile

(Ditto for outgoing string)
0
 
hessAuthor Commented:
Great both of you. One problem though. I asked how to read and WRITE text files so who ever can give me that also will be awarded the points.
0
 
hessAuthor Commented:
Great both of you. One problem though. I asked how to read and WRITE text files so who ever can give me that also will be awarded the points.
0
 
hessAuthor Commented:
I'm Dumb. You can't say ditto for out going file Cliff because it isn't exacly the same and i don't know what changes to make.  I am an absolute begineer
0
 
hessAuthor Commented:
I'm Dumb. You can't say ditto for out going file Cliff because it isn't exacly the same and i don't know what changes to make.  I am an absolute begineer
0
 
clifABBCommented:
It would be much easier if you could give the name(s) of the variable(s) which contain the text you want to save.

However, if you are saving the contents of a text box, use this:
hFile = FreeFile
Open "TESTFILE" For Output As #hFile
Print #hFile, Text1.Text
Close hFile

I will submit this as a comment until you are satisfied with the answer.
0
 
hessAuthor Commented:
Cliff,
         I'll give you the 50 points as soon as you propose an aswer so that i have the option of giving it to you (the answer in the comment was fine).  Thankyou for all of you help.


0
 
hessAuthor Commented:
Cliff,
         I'll give you the 50 points as soon as you propose an aswer so that i have the option of giving it to you (the answer in the comment was fine).  Thankyou for all of you help.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.