Results 1 to 9 of 9

Thread: [RESOLVED] richtextbox selected text add html code start and end

  1. #1

    Thread Starter
    Banned
    Join Date
    Aug 2022
    Posts
    97

    Resolved [RESOLVED] richtextbox selected text add html code start and end

    this is a demo text i love you peace

    this is a demo text i love you peace

    Code:
    this is a demo text <font style="color:red">i love you</font> peace

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: richtextbox selected text add html code start and end

    And your question is?

    The RichTextBox can not show the markup of HTML text.
    So you have to use some other component or convert the HMTL to RTF (RichText Format)

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: richtextbox selected text add html code start and end

    Quote Originally Posted by Arnoutdv View Post
    So you have to use some other component or convert the HMTL to RTF (RichText Format)
    That's actually an interesting idea, and I don't think I've ever seen any VB6 code to do that.

    You could probably automate Word to do it for you though, but a pure VB6 solution would be cool.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: richtextbox selected text add html code start and end

    There are multiple solutions when you Google for HTML2RTF.

    A premade OCX:
    https://vbcoders.com/code/html2rtf-p...ing-27904.html

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: richtextbox selected text add html code start and end

    I guess I'm just too old and feeble, but I can't decipher the pidgin-post above enough to figure out what the OP is trying to ask for.

    This might be useful if the intent is to have a RichEdit control accept HTML markup input. The RichTextBox may wrap too old a version of RichEdit control to do this. In that case the easiest alternative is an InkEdit control.

    RichEdit HTML Support

  6. #6

    Thread Starter
    Banned
    Join Date
    Aug 2022
    Posts
    97

    Re: richtextbox selected text add html code start and end

    Quote Originally Posted by Arnoutdv View Post
    And your question is?

    The RichTextBox can not show the markup of HTML text.
    So you have to use some other component or convert the HMTL to RTF (RichText Format)
    i want the html tags to be inserted at the begining and end of the selection text
    i dont want it converted i need the raw html code inserted only
    Last edited by tuffan; Sep 12th, 2022 at 11:19 AM.

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: richtextbox selected text add html code start and end

    The just add them to the .SelText property of the RTB control

  8. #8
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: richtextbox selected text add html code start and end

    Code:
    Private Sub InsertRedTag()
        Dim iSS As Long
        Dim iSL As Long
        Const cRedTag As String = "<font style=""color:red"">"
        Const cCloseFontTag As String = "</font>"
        
        iSS = RTBControl.SelStart
        iSL = RTBControl.SelLength
        RTBControl.SelLength = 0
        RTBControl.SelText = cRedTag
        RTBControl.SelStart = iSS + Len(cRedTag) + iSL
        RTBControl.SelText = cCloseFontTag
        RTBControl.SelStart = iSS + Len(cRedTag)
        RTBControl.SelLength = iSL
    End Sub

  9. #9

    Thread Starter
    Banned
    Join Date
    Aug 2022
    Posts
    97

    Re: richtextbox selected text add html code start and end

    Quote Originally Posted by Eduardo- View Post
    Code:
    Private Sub InsertRedTag()
        Dim iSS As Long
        Dim iSL As Long
        Const cRedTag As String = "<font style=""color:red"">"
        Const cCloseFontTag As String = "</font>"
        
        iSS = RTBControl.SelStart
        iSL = RTBControl.SelLength
        RTBControl.SelLength = 0
        RTBControl.SelText = cRedTag
        RTBControl.SelStart = iSS + Len(cRedTag) + iSL
        RTBControl.SelText = cCloseFontTag
        RTBControl.SelStart = iSS + Len(cRedTag)
        RTBControl.SelLength = iSL
    End Sub
    :

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