RichTextBox format prob

L

Lespaul36

I am writing lan chat program and want the messages to be color coded for
sent/recieved...you know the standard idea.

I cannot seem to get the richtextbox to keep the color. I do a recieve and
it is fine, I do a send and it is fine, another recieve and all of the text
becomes one color.

Here is the code I am using for the the Recieve..I use the same code for the
send.

Private Sub mobjClient_LineReceived(ByVal sender As Client, ByVal Data As
String) Handles mobjClient.LineReceived

Dim pstrmessage As String = Data
With txtRecieved
If .Text = "" Then
.Text &= pstrmessage
Else
.Text &= vbCrLf & pstrmessage
End If
Dim pintTextLen As Integer = Len(.Text)
Dim pintLoc As Integer = Len(.Text) - Len(pstrmessage)
Dim pintLen As Integer = Len(pstrmessage)
.SelectionStart = pintLoc
.SelectionLength = pintLen
Dim pstrSel As String = .SelectedText
.SelectionColor = Color.Navy
Me.Show()
End With

End Sub

I check the pstrSel and it looks like the corect text is selected, but the
selectioncolor seems to be changin everything. Am I just over looking
something here?
 
L

Lespaul36

Found the answer

With txtRecieved
If .Text <> "" Then
pstrSend = vbCrLf & pstrSend
End If
.SelectionColor = Color.Red
.AppendText(pstrSend)
End With
 
S

Supra

remove this SelectionColor = Color.Navy and put it on top of ur block.
this how i do to prevent randon colour in chat. i do in in irc chat too
similar to mirc/pirch chat.


.SelectionColor = Color.Navy
If .Text = "" Then
\\
\\
\\
Me.Show()

hope this help'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top