Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Text File Help

RonaldSRonaldS Posts: 33Member
The attached code does what I want it to do, but how can I re-save the text file without the double quotes? I tried saving as a text file, a .dat file and as a Word .doc file. All 3 give me the double quotes at the beginning and end of each file.

[code]
Private Sub BeginHere_Click()
Dim TextLine As String
Dim x1 As Long
Dim NumLines As Long
NumLines = Val(NumPages) * 57
ReDim x(1 To NumLines)
Dim FileNom As String
FileNom = NameOfFile.Text
Open "c:UsersRonDesktop" & FileNom & ".txt" For Input As #1
For x1 = 1 To NumLines
Line Input #1, TextLine
If EOF(1) Then Exit For
If Right(TextLine, 1) <> " " Then TextLine = TextLine + " "
x(x1) = TextLine
Label2.Caption = Str(NumLines)
Next x1
Close #1
'-------------------------------------------------------------
Open "c:UsersRonDesktop" & FileNom & ".txt" For Output As #1
For x1 = 1 To NumLines
Write #1, x(x1)
Label2.Caption = Str(NumLines)
Next x1
Close #1
End Sub
[/code]

Comments

  • lionblionb Posts: 1,686Member
    : The attached code does what I want it to do, but how can I re-save
    : the text file without the double quotes? I tried saving as a text
    : file, a .dat file and as a Word .doc file. All 3 give me the double
    : quotes at the beginning and end of each file.
    :
    : [code]:
    : Private Sub BeginHere_Click()
    : Dim TextLine As String
    : Dim x1 As Long
    : Dim NumLines As Long
    : NumLines = Val(NumPages) * 57
    : ReDim x(1 To NumLines)
    : Dim FileNom As String
    : FileNom = NameOfFile.Text
    : Open "c:UsersRonDesktop" & FileNom & ".txt" For Input As #1
    : For x1 = 1 To NumLines
    : Line Input #1, TextLine
    : If EOF(1) Then Exit For
    : If Right(TextLine, 1) <> " " Then TextLine = TextLine + " "
    : x(x1) = TextLine
    : Label2.Caption = Str(NumLines)
    : Next x1
    : Close #1
    : '-------------------------------------------------------------
    : Open "c:UsersRonDesktop" & FileNom & ".txt" For Output As #1
    : For x1 = 1 To NumLines
    : Write #1, x(x1)
    : Label2.Caption = Str(NumLines)
    : Next x1
    : Close #1
    : End Sub
    : [/code]:
    [color=Blue]Use statement 'Print' instead of 'Write'
    [b]Print[/b] #1, x(x1)[/color]
Sign In or Register to comment.