VB5 code, may not work without a few changes:
Dim FileText As String 'Know this worksOpen MyFile For Binary As 1 'Know this worksFileText = Space$(LOF(1)) 'Creates a string the same length as the fileGet #1, , FileText 'Should workCloseDox = InStr(x + 1, FileText, OldText) 'Know this worksIf x 0 ThenFileText = Left$(FileText, x - 1) & NewText & Right$(FileText, Len(FileText) - (x + Len(OldText) - 1)) 'Should workFileChanged = 1ElseExit DoEnd IfLoopIf FileChanged = 1 ThenOpen MyFile For OutPut As 1 'Know this worksClose 'Know this worksOpen MyFile For Binary As 1 'Know this worksPut #1, , FileText 'Should workCloseEnd If
Hope this helps!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
VB5 code, may not work without a few changes:
Dim FileText As String 'Know this works
Open MyFile For Binary As 1 'Know this works
FileText = Space$(LOF(1)) 'Creates a string the same length as the file
Get #1, , FileText 'Should work
Close
Do
x = InStr(x + 1, FileText, OldText) 'Know this works
If x 0 Then
FileText = Left$(FileText, x - 1) & NewText & Right$(FileText, Len(FileText) - (x + Len(OldText) - 1)) 'Should work
FileChanged = 1
Else
Exit Do
End If
Loop
If FileChanged = 1 Then
Open MyFile For OutPut As 1 'Know this works
Close 'Know this works
Open MyFile For Binary As 1 'Know this works
Put #1, , FileText 'Should work
Close
End If
Hope this helps!