BILAL69
asked on
Color Problem with Rich Text Box vb6
Hello, I am working on a messenger which has some chat rooms now the problem is when someone enters/leave a room it show in blue that user has entered/left but after a while when someone else enter/leave all the old textformatting comes to defualt (black) here is my code:
Public Sub AddStatusMessage(RTB As Object, _
ByVal Color As Long, Message As String)
If Not TypeOf RTB Is RichTextBox Then Exit Sub
With RTB
.SelStart = Len(.Text)
.SelFontName = "Tahoma"
.SelFontSize = 9
.SelBold = False
.SelItalic = False
.SelUnderline = False
.SelColor = Color
.SelText = Message & vbCrLf
End With
End Sub
IT works quite fine but how to remain other colors
Public Sub AddStatusMessage(RTB As Object, _
ByVal Color As Long, Message As String)
If Not TypeOf RTB Is RichTextBox Then Exit Sub
With RTB
.SelStart = Len(.Text)
.SelFontName = "Tahoma"
.SelFontSize = 9
.SelBold = False
.SelItalic = False
.SelUnderline = False
.SelColor = Color
.SelText = Message & vbCrLf
End With
End Sub
IT works quite fine but how to remain other colors
ASKER
well i only use this code when someone enter/leave so.. when its not i just say txtChat.text = txtChat.text & themsg & vbcrlf
also how do i know the color in RGB() ? like if i want the pink color :-/
also how do i know the color in RGB() ? like if i want the pink color :-/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oh correct thnx :D
The symptom of losing all previous formatting and everything going to black is usually caused by setting the Text() property:
RTB.Text = RTB.Text & "new message" & vbCrLf ' <---- this is wrong way to go about it
Do you have any other code that deals with the RichTextBox?...and if so, does it directly assign the Text() Property like above?