?
Solved

Open/save text

Posted on 1998-06-26
15
Medium Priority
?
145 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses

850 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