Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

one more text writing question

Status
Not open for further replies.

mettodog

Vendor
Jul 11, 2000
94
US
ok, i want my prog to search out for the last string in a text(html) file, and write:
&quot;<br> <a href=&quot;notes/(variable goes here)&quot;>(variable goes here too</a><br>

how would i go about doing this? questions/comments greatly appreciated.
 
You will have to read the entire file, line by line checking to see if there is a line after the one that has been read. If there is, write this line to another file and go on and read the next line and check again. If there is not, write out you extra line and then write out the last read in line.

Do you need sample code for this??

Simon
 
...or you could read the entire file in one operation, find the last line and replace it. Like this...
[tt]
LastLine$ = &quot;<br> <a href=&quot; & Chr$(34) & &quot;notes/&quot;
LastLine$ = LastLine$ & &quot;(variable goes here)&quot;
LastLine$ = LastLine$ & Chr$(34) & &quot;>&quot;
LastLine$ = LastLine$ & &quot;(variable goes here too)&quot;
LastLine$ = LastLine$ & &quot;</a><br>&quot; & vbCrLf
ff = FreeFile
Open &quot;c:\my.html&quot; For Binary As #ff
G$ = String$(LOF(ff), 32)
Get #ff, 1, G$
Cr = InStr(G$, vbCrLf)
For Rep = Len(G$) - 2 To 1 Step -1
If Mid$(G$, Rep, 2) = vbCrLf Then
FoundLast = Rep + 1
Exit For
End If
Next
P$ = Left$(G$, FoundLast) & LastLine$
Put #ff, 1, P$
Close #ff
[/tt]

There are probably many ways you can do this.
VCA.gif

Alt255@Vorpalcom.Intranets.com
 
yes, please show me some sample code, it would help a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top