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

Writeing to a file please help

Status
Not open for further replies.

DUF

Technical User
Mar 10, 2001
107
0
0
IE
I tryed to use the following code
Private Sub Command1_Click()
Open "c:\my documents\Port.txt" for output as #
Write #1,N
Write #1,B10,10,0,3,3,7,200,B,"987654321"
Write #1,P1
close #1

It will not write the strings (as in N,B10,B,P1)
to the file it will only write the numbers

Now I know that if I use the quotation (") it will write them to file

But I need the string in the file without the quotation
markes.
I need it looking like this
N
B10,10,0,3,3,200,B10,"987654321"
P1


and not like this

"N"
"B10,10,0,3,3,200,"B10","987654321"
"P1"

can any one help I am new to VB

thanks

Duf



 
Sorry, let me expand:
Code:
Open "c:\my documents\Port.txt" for output as #1
Print #1,"N"
Print #1,"B10,10,0,3,3,7,200,B,""987654321""
Print #1,"P1"
close #1

The double "" *should* show up in the file as a " with out ending your string. If that doesn't work use:
Code:
Print #1,"B10,10,0,3,3,7,200,B," & chr(34) & "987654321" & chr(34)
Kevin
 
Why not use BV6 power and use Microsoft Scripting Runtime ?

Here is the code :

Dim oFso As New FileSystemObject
Dim sTextStream As TextStream
With oFso
Set sTextStream = .OpenTextFile("c:\temp\test.txt", ForWriting, True)
sTextStream.WriteLine ("N")
sTextStream.WriteLine("B10,10,0,3,3,7,200,B,""987654321""")
sTextStream.WriteLine ("P1")
Set sTextStream = Nothing
End With
Set oFso = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top