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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print double quotes in a text file

Status
Not open for further replies.

meenakshidhar

Programmer
Oct 19, 2001
77
MY
hi..
can anybody tell me how to print "double quotes" in a text file...
e.g.
myvar=1234

in file it should print "1234"

Regards
Meenakshi Dhar

 
Anytime you need to print double quotes you can use 2 double quotes as an escape character, like so:
Code:
Response.Write "myvar=[highlight]""[/highlight]2345[highlight]""[/highlight]"

This works the same when printing to files as well. (The response.Write was just an easier example :) )

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
It's not wrking with the files...
My code is given below

Filename="test.txt"
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile(FileName, 2, True)

myvar=1234
Stuff=myvar
WriteStuff.WriteLine(Stuff)

Now in test.txt , it shld print "1234"

Regards,
Meenakshi Dhar
 

Add the ASCII code for quotes to the variable

Code:
stuff = chr(34) & stuff & chr(34)



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Quotes don't auto-magically apear, you have to add them.

Also, if you want "1234" in the text file your close, if you want myvar="1234" in the file, you have a logic error.
Code:
myvar=1234
Stuff=myvar         
WriteStuff.WriteLine(Stuff)

[b]Should be:[/b]
Stuff = "myvar=""1234"""
WriteStuff.WriteLine(Stuff)

1234 in you code isn't even a string, it's a number (no quotes around it). Setting myvar = 1234 and then setting Stuff = myvar means that Stuff is now storing the number 1234, nothing more and nothing less.


01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top