Results 1 to 5 of 5

Thread: Adding RTF commands to string

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    53

    Adding RTF commands to string

    Im trying to make a word underlined within a string and then add the string to a RichTextBox...

    I recive a text and in that string are 2 Chr(31) and i replaces them with the RTF underline commands that you can find in a .rtf file.

    When the text got added to the RichTextBox, it shows the "\ul" and "\ulnone" as text!?! How can i get it to show the word underlined?

    Code:
    Public Sub Something(sText as string)
    
          sText = Format(sText, vbCFRTF)
          
          sText = Replace(sText, Chr(31), "\ul ", , 1)	'This is the start of a underline
          sText = Replace(sText, Chr(31), "\ulnone ", , 1)	'This is the end of the underline
    
          RichTextBox.SelText = sText 'Have alse tried with .SelRTF
    
    End Sub
    You are reading my signature! :-)

    My WIP site

    Three Great bands:
    Beseech
    Meshuggah
    Opeth

  2. #2
    Addicted Member
    Join Date
    Nov 2003
    Location
    India
    Posts
    227
    Try this.

    VB Code:
    1. Public Sub Something(sText as string)
    2.       RichTextBox.SelText = sText
    3.       RichTextBox.SelStart =       RichTextBox.SelStart - Len(SText)
    4.       RichTextBox.SelLength = Len(SText)
    5.       RichTextBox.SelUnderline = True
    6. End Sub
    See you,
    -Jai
    [Friends Never Say Good Bye]

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    53
    Nope that doesn´t work...

    That you wrote makes all in the sText underlined.. Thats not what i want..
    I want it to just underline ONE WORD... That has Chr(31) before and after.
    You are reading my signature! :-)

    My WIP site

    Three Great bands:
    Beseech
    Meshuggah
    Opeth

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    53
    Anyone?
    You are reading my signature! :-)

    My WIP site

    Three Great bands:
    Beseech
    Meshuggah
    Opeth

  5. #5
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    Just customize the following procedure according, i think u can do that now


    VB Code:
    1. Public Sub UnderlineString(objRTB As RichTextBox, strWord As String)
    2. objRTB.TextRTF = Replace(objRTB.TextRTF, strWord, "{\rtf1\ansi\ansicpg1252\ul " & strWord & "\ulnone}", , , vbTextCompare)
    3. End Sub
    Last edited by ravi15481; Dec 11th, 2003 at 06:31 AM.
    A good friend...

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