Results 1 to 4 of 4

Thread: HTMLising TXT

  1. #1
    Guest

    Post

    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.

  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    173

    Post

    Use the Instr function to loop through every character looking for the vbCrlf character. When found, append a <br> tag and carry on looking.

  3. #3
    Guest

    Post

    Yeah, I get the idea:
    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
    but I get an "Invalid Procedure Call or Argument" on the InStr (4th) line. Help.

    ------------------
    Matthew Ralston
    E-Mail: [email protected]
    ICQ:31422892
    Web Sites:The Blue Link My Home Page


  4. #4
    Addicted Member
    Join Date
    Jan 1999
    Posts
    173

    Post

    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!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width