Consulting

Results 1 to 4 of 4

Thread: write

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    write

    HI
    i have this macro for openning and reading the text file.
    [VBA]Option Explicit

    Sub Read_text_File()

    Dim oFSO As New FileSystemObject
    Dim oFS
    Dim stext As String




    Set oFS = oFSO.OpenTextFile("C:\Documents and Settings\oleg_volfson\Desktop\results.TXT")

    Do Until oFS.AtEndOfStream
    stext = oFS.ReadLine

    MsgBox stext
    Loop


    End Sub
    [/VBA]
    how can i after "MsgBox stext" write in the text file "operation1","operation2" and so on


    thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub Read_text_File()
    Dim File1 As Long
    Dim File2 As Long
    Dim filename1 As String
    Dim filename2 As String
    Dim stext As String

    File1 = FreeFile
    filename1 = "C:\test.txt" '"C:\Documents and Settings\oleg_volfson\Desktop\results.TXT
    Open filename1 For Input As File1
    File2 = FreeFile
    filename2 = "C:\test2.txt" '"C:\Documents and Settings\oleg_volfson\Desktop\results2.TXT
    Open filename2 For Output As File2

    Do While Not EOF(File1)
    Input #File1, stext
    MsgBox stext
    Print #File2, stext
    Print #File2, "some more"
    Loop

    Close File1
    Close File2

    Kill filename1
    Name filename2 As filename1

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    HI
    i am sorry for the cross posting i just did know
    what to do i needed the answer very badly my boss pushing and gave
    a dead line.
    from know on there will be no cross posting and if will intend to
    will ask for your permission.

    sorry
    i love this forum and the people that give up there free
    time to help
    some one like me

    Thanks

    Oleg

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Don't you dare ask my permission, I am not your overseer. Just let us know so that we can make informed choices.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •