Reputation: 45
i have a problem right now. Im using textfile as my database. Here is the format of my Strings inside the textfile.
01/Alarm1/01:00:00
01/Alarm2/02:00:00
01/Alarm3/03:00:00
For example i just want to rename the Alarm2 but it will keep the 01 on the beginning and the time on it. Thanks for help guys
Upvotes: 1
Views: 5864
Reputation: 55
loop begin
loop end
close both files
Upvotes: 0
Reputation: 743
Please find an example on which you can rely on in order to:
Hope this will help you.
Dim FSO As FileSystemObject
Dim TS As TextStream
Dim TempS As String
Dim Final As String
Set FSO = New FileSystemObject
Set TS = FSO.OpenTextFile("mydata.txt", ForReading)
Do Until TS.AtEndOfStream
TempS = TS.ReadLine
'if TempS contains Alarm2 => rename Alarm
Final = Final & TempS & vbCrLf
Loop
TS.Close
Set TS = FSO.OpenTextFile("mydata.txt", ForWriting, True)
TS.Write Final
TS.Close
Set TS = Nothing
Set FSO = Nothing
Upvotes: 2