|
-
Dec 10th, 2003, 08:47 AM
#1
Thread Starter
Member
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
-
Dec 10th, 2003, 08:57 AM
#2
Addicted Member
Try this.
VB Code:
Public Sub Something(sText as string)
RichTextBox.SelText = sText
RichTextBox.SelStart = RichTextBox.SelStart - Len(SText)
RichTextBox.SelLength = Len(SText)
RichTextBox.SelUnderline = True
End Sub
See you,
-Jai
[Friends Never Say Good Bye]
-
Dec 10th, 2003, 09:09 AM
#3
Thread Starter
Member
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.
-
Dec 11th, 2003, 06:02 AM
#4
Thread Starter
Member
-
Dec 11th, 2003, 06:25 AM
#5
Hyperactive Member
Just customize the following procedure according, i think u can do that now
VB Code:
Public Sub UnderlineString(objRTB As RichTextBox, strWord As String)
objRTB.TextRTF = Replace(objRTB.TextRTF, strWord, "{\rtf1\ansi\ansicpg1252\ul " & strWord & "\ulnone}", , , vbTextCompare)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|