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!

How do i remove the quotes after using write#

Status
Not open for further replies.

cmcgann

Programmer
May 31, 2000
22
0
0
IE
Hello All,

I am having trouble writing to a text file, i have managed to replace all the quotes and commas with "". But i cannot get rid of the Leading and ending quotes.

E.g

"Line55234123412" )- this is what i get

Line55234123412 :- this is what i want

thanks in advance

Conor



 
Suppose the "Line55234123412" is stored in a vaiable
called qstring you need only state:

Replace(qstring, chr$(34), " ")

and the quotes are gone.
 
If you changed the 'Write#' to 'Print#', you won't get any quotes either.

David Paulson


 
I tried using the print but this formats the data incorrectly. Also the Replace function does not work because
after i replace i have to write it back out again.....and this adds quotes.

Thanks again for your replys

Conor
 
There is only one sure way to write what you intend to write and read what you intend to read. That's using binary access with Get and Put statements.

Try it out. Place a Drive listbox, a Dir listbox and a File listbox on a form and use this code:
[tt]
Private Sub Dir1_Change()
File1 = Dir1
End Sub

Private Sub Drive1_Change()
Dir1 = Drive1
End Sub

Private Sub File1_Click()
ReDim Txt$(1 To 1)
ff = FreeFile
Fname$ = Dir1.Path
If Right$(Fname$, 1) <> &quot;\&quot; Then Fname$ = Fname$ & &quot;\&quot;
Fname$ = Fname$ & File1.FileName
Open Fname$ For Binary As #ff
G$ = String$(LOF(ff), 0) 'get the entire file in one string
Get #ff, 1, G$
Close #ff
Do 'parse the string into the Txt$ array
NextCrlf = InStr(LastCrlf + 1, G$, vbCrLf, vbBinaryCompare)
If NextCrlf < 1 Then Exit Do
If LastCrlf = 0 Then 'It's the first line of text
Txt$(UBound(Txt$)) = _
[tab][tab]Mid$(G$, LastCrlf + 1, NextCrlf - LastCrlf - 2)
Else
Txt$(UBound(Txt$)) = _
[tab][tab]Mid$(G$, LastCrlf + 2, NextCrlf - LastCrlf - 2)
End If
If MsgBox(&quot;Seen enough?&quot; & vbCrLf & _
[tab][tab]Txt$(UBound(Txt$)), vbYesNo) = vbYes Then End
[tab]'make room for more lines of text
[tab]ReDim Preserve Txt$(1 To UBound(Txt$) + 1)
LastCrlf = NextCrlf
Loop
End Sub
[/tt]

Then click on a text file in the file listbox. You will see the true contents of each line of the text file.

I think this will help.
VCA.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top