PDA

Click to See Complete Forum and Search --> : HTMLising TXT


Nov 24th, 1999, 09:54 PM
What's the easiest way to go through the contents of a multiline text box and append "<br>" (without the quotes) to the end of each line?

It's part of a cgi program that lets the user open a text file and send it to the browser as a web page.

vbsquare
Nov 28th, 1999, 04:56 AM
Use the Instr function to loop through every character looking for the vbCrlf character. When found, append a <br> tag and carry on looking.

Nov 28th, 1999, 08:46 PM
Yeah, I get the idea:

Dim iPosition As String
iPosition = 0
While iPosition <= Len(txtReply)
iPosition = InStr(iPosition, txtReply, vbCrLf)
If iPosition <> 0 Then
txtReply = Left(txtReply, iPosition) & "<br>" & Right(txtReply, Len(txtReply) - iPosition)
End If
Wend

but I get an "Invalid Procedure Call or Argument" on the InStr (4th) line. Help.

------------------
Matthew Ralston
E-Mail: m.ralston@mediavault.co.uk
ICQ:31422892 (http://195.89.158.103/icq.html)
Web Sites:The Blue Link (http://195.89.158.103) My Home Page (http://mralston.cjb.net)

vbsquare
Nov 28th, 1999, 08:51 PM
Dim NextChar As String * 1
Dim strNew As String
For i% = 1 To Len(Text1.Text)
NextChar$ = Mid(Text1.Text, i, 1)
If NextChar$ = Chr(13) Then
strNew = strNew & "<br>" & LineText$
LineText$ = ""
ElseIf NextChar$ = Chr(10) Then
Else
LineText$ = LineText$ & NextChar$
End If
Next

------------------
"To the glory of God!"