Hi,
I am opening a text file and finding a string say 001# till EOF and then replacing it. Once the replacement is done I want to find another string say 003# in the complete file and replace it with another string. This way I need to find around 15 strings and replace them. And in the end close the file.
But i do not know what the problem is with the code.
My code is like this
Private Sub Main()
Dim intext As String
Dim outtext As String
Open "C:\test.txt" For Input As #1
Open "C:\certi.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, intext
If InStr(1, intext, "001#") > 0 Then
outtext = Replace(intext, "001#", "|")
Print #2, outtext
End If
If InStr(1, intext, "002#") > 0 Then
outtext = Replace(intext, "002#", "")
Print #2, outtext
End If
Loop
Close
End Sub
I am opening a text file and finding a string say 001# till EOF and then replacing it. Once the replacement is done I want to find another string say 003# in the complete file and replace it with another string. This way I need to find around 15 strings and replace them. And in the end close the file.
But i do not know what the problem is with the code.
My code is like this
Private Sub Main()
Dim intext As String
Dim outtext As String
Open "C:\test.txt" For Input As #1
Open "C:\certi.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, intext
If InStr(1, intext, "001#") > 0 Then
outtext = Replace(intext, "001#", "|")
Print #2, outtext
End If
If InStr(1, intext, "002#") > 0 Then
outtext = Replace(intext, "002#", "")
Print #2, outtext
End If
Loop
Close
End Sub