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.
Printable View
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.
Use the Instr function to loop through every character looking for the vbCrlf character. When found, append a <br> tag and carry on looking.
Yeah, I get the idea:
but I get an "Invalid Procedure Call or Argument" on the InStr (4th) line. Help.Code: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
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ:31422892
Web Sites:The Blue Link My Home Page
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!"