|
-
October 20th, 1999, 06:35 PM
#1
how to add text to the txt file.....
I need to add a line to the .txt file, but i need it to add after specific line, not first line or last line of text...So how can i search for that line and tell vb to add new line after specific line....not replace the specific, add.....
-
October 20th, 1999, 09:37 PM
#2
Re: how to add text to the txt file.....
Look for new-line characters - vbCrlf
Count that many, say N, and break the text after that point by copying into another text buffer with Mid$ -(May have some touble, if that buffer is too big!)
i = 0:j = 1
do
breakat = Instr(j, tmpbuf,vbcrlf)
if breakat = 0 then
' no more new lines!!. error
exit do
else
j = j + breakat + len(vbcrlf) '
i = i + 1
end if
if i = n then
tmpbuf1 = mid$(tmpbuf,j + len(vbcrlf)
tmpbuf = left$(tmpbuf,j-1)
end if
loop
' add some code here to catch the error, if we
' could not find 'n' no.of line breaks
' assuming no error..
tmpbuf = tmpbuf & vbcrlf & new_string & vbcrlf & tmpbuf1
RK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|