[RESOLVED] Manipulate Text File
I saw this example in another thread and decided it would make a good example for me to learn VBs file manipulation syntex. That thread is closed so I was asked to start a new thread.
Lets say this data was in a file and it had numerous records. I think I'm close down there, but am doing something wrong. Thanks!
ps. I guess what I'm trying to come up with is a standard way to open and write a file, and use the middle area to manipulate the text.
MyString.txt.
1This is the string I want to keep.****12/1/2006 USG8503
2This is the string I want to keep.****12/1/2006 USG8503
3This is the string I want to keep.****12/1/2006 USG8503
4This is the string I want to keep.****12/1/2006 USG8503
[Highlight=VB]
Private Sub cmdClick()
Dim sFileInfo() As String
Dim i As Long
Open "C:\MyString.txt" For Input As #1
sFileInfo(i) = Left$(i, Len(i) - 21)
Close #1
Open "C:\AllFixedUp.txt" For Append As #1
Print #1, sFileInfo(i)
Close #1
Next
End Sub
Re: [RESOLVED] Manipulate Text File
VB Code:
Dim ff As Integer
Dim mystring As String
ff = FreeFile
Open "C:\MyString.txt" For Input As #ff
mystring = Input(LOF(ff), #ff)
mystring = Replace(mystring, Right(mystring, 21), "")
Close #ff