Solved

Open/save text

Posted on 1998-06-26
15
141 Views
Last Modified: 2010-05-03
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)
0
Comment
Question by:hess
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
15 Comments
 

Author Comment

by:hess
ID: 1464414
Edited text of question
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1464415
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
 

Author Comment

by:hess
ID: 1464416
I needds to read more than one line
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:hess
ID: 1464417
The answer proposed by clifABB only reads only line of text
0
 

Author Comment

by:hess
ID: 1464418
The answer proposed by clifABB only reads only line of text
0
 

Expert Comment

by:electrick
ID: 1464419
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
 
LVL 6

Expert Comment

by:clifABB
ID: 1464420
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
 

Author Comment

by:hess
ID: 1464421
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
 

Author Comment

by:hess
ID: 1464422
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
 

Author Comment

by:hess
ID: 1464423
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
 

Author Comment

by:hess
ID: 1464424
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
 
LVL 6

Expert Comment

by:clifABB
ID: 1464425
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
 

Author Comment

by:hess
ID: 1464426
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
 

Author Comment

by:hess
ID: 1464427
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
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1464428
Here is the answer:
hFile = FreeFile
Open "TESTFILE" For Output As #hFile
Print #hFile, Text1.Text
Close hFile

Glad I could help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question