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

insert quotes in txtfile

Status
Not open for further replies.

moogeboo

MIS
Aug 7, 2003
28
US
hi,

i have this script to take input from a user:

dim fso, wshshl, fil,oShell, strExec, fullname
dim txtFile
set wshshl = wscript.createobject("wscript.shell")
set fso = createobject("Scripting.FileSystemObject")
set oShell=Wscript.CreateObject("Wscript.Shell")
fullname = inputbox("Enter in Full Name to be assigned to Client", "Fullname")

Set txtFile = fso_OpenTextFile("c:\a.xt", 2, True)
'Change 2 to 8 if you want to append to file

txtFile.WriteLine "Name = " & fullname
txtFile.Close

My problem is that when a user enters in spaces between the name, i.e, john doe
the output that is written to a.txt is: john doe
However, I need to insert quotes around the john doe, like "john doe" on the txt file because it is being read by another
program, and it needs quotes around the variable otherwise it will be truncated with just "john".
I pretty sure this is simple, but i'm just learning vb script, so i'm wondering if anyone can help.

thanks,
 
Try something like this:
Code:
txtFile.WriteLine "Name = """ & fullname & Chr(34)
To insert double quote into a string, either use Chr(34) or double typed double quote.


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top