TXT File open, modify, save as new (RESOLVED)
got this to start off
Code:
Private Sub mnuConvert_Click()
Call mnuCloseLog_Click 'Close Log file first
Open Temp For Input As #1 'Open log file
Open NewLogFile For Append As #2
Close #2
Close #1
End Sub
want to open a log file, stored in (Temp) delete the then save to another file (NewLogFile), whats the best way to do this, please use code i already have and decare any variables
thanks in advance :afrog:
Re: TXT File open, modify, save as new
ok got this
Code:
strFind = "" 'What To find
strReplace = "" 'What To replace it With
strDestination = CommonDialog1.FileName 'Where To put the files once they have been modified
strSource = Temp 'Where To Get the files
strFilter = "*.txt" 'wildcards
'verification complete
Dim Parse As String
Dim Hold As String
'FIND AND REPLACE
Open strSource For Input As #1 'Open log file
Do While Not EOF(1)
Line Input #1, Parse
'Hold = Hold & replace(Parse, strReplace, strFind)
Hold = Hold & replace(Parse, strFind, strReplace)
Loop
Open strDestination For Output As #2
Print #2, Hold
Close #2
Hold = ""
Parse = ""
Close #1
but it doesnt seem to be working, not taking out the in txt files??, however need the txt files as is with the line feed and character returns
please help
Re: TXT File open, modify, save as new
strFind = Chr$(0) 'What To find
I think it is null
1 Attachment(s)
Re: TXT File open, modify, save as new
nope that didnt work, also i seem to be losing my return(enter) and string fits on 2 lines where i want to have as original txt file (log) as attached without the squares in
Re: TXT File open, modify, save as new
VB uses ascii 10 and 13 for vbCrLf
Word only uses 10.
Not sure about a .txt
1 Attachment(s)
Re: TXT File open, modify, save as new
I have made one for along time. Create File, Append and Open File. If it's help please let me know.
thanks.
Habibalby
Re: TXT File open, modify, save as new
is it possible to write a string to file without the (") sign???
Re: TXT File open, modify, save as new
sorry havent used your code but got this working
Code:
strReplace = "" 'What To replace it With
strDestination = CommonDialog1.FileName 'Where To put the files once they have been modified
strSource = Temp 'Where To Get the files
strFilter = "*.txt" 'wildcards
'verification complete
Dim Parse As String
Dim Hold As String
'FIND AND REPLACE
Open strSource For Input As #1 'Open log file
Open strDestination For Output As #2
Do While Not EOF(1)
Line Input #1, Parse
'Hold = Hold & replace(Parse, strReplace, strFind)
'strFind = Chr(10) 'What To find
Hold = replace(Parse, "", strReplace)
Hold = replace(Hold, "", strReplace)
Hold = replace(Hold, "", strReplace)
Print #2, Hold
Loop
Hold = ""
Parse = ""
Close #1
Close #2
cheers
Re: TXT File open, modify, save as new (RESOLVED)
Re: TXT File open, modify, save as new (RESOLVED)
thanks will be back on next problem