|
-
Jun 24th, 2002, 03:46 AM
#1
Thread Starter
PowerPoster
Select Specific Text in the RichTextBox
Ok I have a RichTextBox, which is used as the main chat window of my app.
So it would be like,
User1: Message
User2: Message
I want to bold the "User1:" and "User2:"
I was thinking I might search along the line until I find the first :
But of course I don't have any code for this, any help would be great.
-
Jun 24th, 2002, 04:34 AM
#2
Lively Member
Hi,
You could use instring to find the position of the ':' then SelStart SelLength to select the text and then make it bold.
Hope this helps,
Chris
-
Jun 24th, 2002, 05:26 AM
#3
Lively Member
In richtextbox lines can not be read, otherwise ur problem would be easy.
try this,
Dim MyPos as integer
Private Sub Command1_Click()
tmpstr = "User1:"
With RichTextBox1
MyPos = Len(.Text)
.Text = .Text + vbCrLf + tmpstr
.SelStart = MyPos + 2
.SelLength = 5
.SelBold = True
End With
End SUb
-
Jun 24th, 2002, 05:31 AM
#4
Thread Starter
PowerPoster
Hmm thats going to be hard, as I'm not sure what the Username will be.
-
Jun 24th, 2002, 05:53 AM
#5
Lively Member
I hope this works,
VB Code:
Dim mypos As Integer
Private Sub Command1_Click()
Dim Position As Integer
tmpstr = txtusernm.text & ":" & txtmsg.text
With RichTextBox1
mypos = Len(.Text)
.Text = .Text + vbCrLf + tmpstr
Position = 0
Position = .Find(":", mypos + 1, , FindFlags)
If Position >= 0 Then
.SelStart = mypos + 2
.SelLength = Position - (mypos + 1)
.SelBold = True
End If
End With
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|