Re: search,read,write & replace in a textfile
if you add ; the event the close #1 doesn't add crlf but if not add ; it will add crlf. i have tried it. and wayne i forgot to mention when the form is unloaded there is a replacement with the text on the textfile and i have known that i forgot the ; at the end of print command. sorry about that. and the case is close :D thanks alot for your help and thanks too for wizbang
:wave:
Re: search,read,write & replace in a textfile
The Join() function does not add anything to the end of the string, so if you get an extra CrLf, then your array has an empty string for the last element. This can happen if the original file has an extra CrLf. There are a few ways to fix this depending on the data in your file, and it's probably a good idea to handle it anyway so that the file doesn't grow over time with empty lines. One easy way is to loop backwards through the string before you split it, and clip off any extra CrLf's which might be there.
Also, I noticed on your last post showing how you are adding to the array, that you are making a second array and copying all the contents from the first, inserting the new line. This is not necessary if you use Redim Preserve on the original array, and just copy the elements from the insertion point up one element (as in S(j + 1) = S(j)).
Re: search,read,write & replace in a textfile
wizbang,
thanks alot. i forgot the preserve keyword so i used 2 array :o now my program is a bit shorter :) the print function without using ; followed by close function is add a vbcrlf at the end of file
thanks for your explanation and your help