Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Omitting quotes when writting to file - how? 1

Status
Not open for further replies.

MikeBronner

Programmer
May 9, 2001
756
US
I know this must be one of the simpler things in VB, but I couldn'r find any solutions so far.

I would like write to a file (text file with .cfg extension), however, I don't wan't the quotes to be written in with the text that is saved.

Is there any way to accomplish this? Best Regards and many Thanks!
Michael G. Bronner X-)

"Beer is proof that God wants us to be happy." Ben Franklin
 
Which quotes?

Show us some code so we know what it is you want to do.

Jordi Reineman
 
Sure thing... this is my code as it stands now (barebones version):


Open app.path & "File.cfg" for output as #1
Write #1, "This is the string I'm writing."
close #1


Now this will write to the file, all well and good. However, the content of the file contains quotes around the string:

"This is the string I'm writing."
"This is the string I'm writing."
"This is the string I'm writing."
"This is the string I'm writing."

(If run multiple times.) I would like it to look like this:

This is the string I'm writing.
This is the string I'm writing.
This is the string I'm writing.
This is the string I'm writing.

Any ideas? Thanks! Best Regards and many Thanks!
Michael G. Bronner X-)

"Beer is proof that God wants us to be happy." Ben Franklin
 
Open app.path & "File.cfg" for output as #1
print #1, "This is the string I'm writing."
close #1

And I hope you will use freefile to get the handle Peter Meachem
peter@accuflight.com
 
Thanks! I'll try that out first thing tomorrow.

Btw: what is freefile? Best Regards and many Thanks!
Michael G. Bronner X-)

"Beer is proof that God wants us to be happy." Ben Franklin
 
Freefile supplies a file number that is not already in use.

Where you have #1 you should use an integer value (e.g. intFileNum), then before you open the file do:

intFileNum = Freefile

Otherwise you could get problems if the file #1 is already in use.

Cheers,

Madlarry
 
Thanks!

Learning new things everyday :). I make a habbit of closing each file immediately after use, but I'll impliment this safeguard as well.

Take Care. Best Regards and many Thanks!
Michael G. Bronner X-)

"Beer is proof that God wants us to be happy." Ben Franklin
 
Contrary to earlier hopes that you will use Freefile, I hope that you will start using the FileSystemObject.

The Open #filenum etc stuff is deprecated. It won't exist in future versions of VB (eg VB.NET)

Whilst the current version of the FSO tends to be limited to text files the next version won't be.
 
But isn't that a bit like saying I won't UK pounds because we are going to use Euros in the next couple of years (hopefully). We aren't using future versions of VB, we are using this one, so why not use the facilities it has. Peter Meachem
peter@accuflight.com
 
Then again, how do to use FSO to read 16 bytes starting at the 63723472th byte of a file?
VCA.gif

Alt255@Vorpalcom.Intranets.com​
 
Off topic, but I assume that Mr Yingling is not from the UK. I think it is a bit complicated actually. And by 'all that code'. We are talking three lines here. Peter Meachem
peter@accuflight.com
 
Well, it's horses for courses. Frankly, I find the FileSystemObject much more powerful and flexible where text file handling is concerned than the older open # etc. facilities. The FSO also encapsulates other useful methods (and doesn't suffer some of the drawbacks of the older stuff; e.g. GetFolder is recursive whilst Dir$ isn't)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top