Results 1 to 13 of 13

Thread: rich text box help, I really need help

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Question

    Hello every body.

    I have some problem with my chatprogram. I would like to have a richtextbox so that I can get incoming messages in a different color, font and I like it bold and italic. I would also like to get the next message at a new row.

    I've tried a lot of ways, I can get it bold and italic but the color doesn't change with .SelColor. If I use a loop I can get different colors but the first word always stays black or default color.

    I've tried vbCrLf to get it to change row but that doesn't work either. I have also tried Chr(10) & Chr(13), it failed too.

    Can anybody help me??
    Does anybody know about a site that explains the rtb and all its programming secrets??
    I would be most grateful if I could get some help.

    Best regards
    Maxon
    Maxon

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    For a new line:
    Code:
    rtb1.Text = rtb1.Text & vbNewLine & "Hello"

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Smile thank you

    Thank you very much. One problem less.
    Best regards
    Maxon

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    could you show me the code which u r using to attempt the change of color? then i might be able to help some more.

  5. #5
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204
    send the server like a code to make it bold like /txtb that whould be helpfully mite me a hard way but an easy way at the same time
    WHat would we do with out Microsoft.
    A lot more.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Question Here's a little test program

    Hello and thanks for your will to help me. I have put together a little test program that simulates incoming and outgoing messages.

    Option Explicit

    Const Red = &HFF&
    Const Blue = &HFF0000
    Dim t As String
    Dim f As String

    Private Sub txt1_KeyPress(KeyAscii As Integer)
    f = "from: "
    If KeyAscii = 13 Then
    With rtftest
    .SelLength = Len(txt1.Text)
    .SelColor = Blue
    .SelBold = True
    .TextRTF = rtftest.Text & vbNewLine & f & txt1.Text
    .SelStart = Len(rtftest.Text)
    .SelBold = False
    End With
    txt1.Text = ""
    txt2.SetFocus
    End If
    End Sub

    Private Sub txt2_KeyPress(KeyAscii As Integer)
    t = "to: "
    If KeyAscii = 13 Then
    With rtftest
    .SelLength = Len(txt2.Text)
    .SelColor = Red
    .TextRTF = rtftest.Text & vbNewLine & t & txt2.Text
    .SelStart = Len(rtftest.Text)
    End With
    txt2.Text = ""
    txt1.SetFocus
    End If
    End Sub

    What happen is that when I send one outgoing message to RTB it format it like it should but then I send the next incoming message and then it changes the whole RTB content to the new format.

    Can I somehow keep the format to a separate line???

    This is the main problem. Hope there is a solution and some of you know about it. I would be most greatful.
    ps. Do I need a error routine in this proceedure, do you think??
    Best regards
    Maxon

  7. #7
    Guest
    To add a new line to the cursor position.
    Code:
    RTB.SetFocus
    RTB.SelText = vbNewLine

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Smile

    Thank you. All suggestions are welcome. I will try that out.

    Best regards
    Maxon

  9. #9
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    you shouldn't mix .TextRTF and .Text

    i can't work out how it should be done either.

  10. #10

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Cool

    Hello. I would like to thank you for trying.
    Well, I will keep on trying and I let you know if I solve the problem.

    For now
    Maxon

  11. #11
    Guest
    Originally posted by da_silvy
    you shouldn't mix .TextRTF and .Text

    i can't work out how it should be done either.
    TextRTF sets the text of a RichTextBox control, including all .RTF code

  12. #12
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    yeah, but if you add .text to .textrtf it doesn't keep it's formatting....


  13. #13

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    6

    Wink Keep on learning

    Hello again. I will try to replace all text with textRTF and I will let you know if I succed. I will go to the university library tomorrow and see if they got any books that will reveal any secrets about RTB. I'll let you know.
    Best regards
    Maxon

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