PDA

View Full Version : write



oleg_v
09-15-2010, 05:06 AM
HI
i have this macro for openning and reading the text file.
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

how can i after "MsgBox stext" write in the text file "operation1","operation2" and so on


thanks

Bob Phillips
09-15-2010, 05:51 AM
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

oleg_v
09-15-2010, 06:28 AM
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

Bob Phillips
09-15-2010, 06:31 AM
Don't you dare ask my permission, I am not your overseer. Just let us know so that we can make informed choices.