Jump to content

Using rich text box for chat?


Damian666

Recommended Posts

so... im trying to get colored chatlines instead of the boring black on white, i tried lots of shit, but it just doesnt work xd

    Public Sub AddText2(ByVal Msg As String, ByVal Color As Long)

        With frmMainGame.txtChat2
            .SelectionColor = Drawing.ColorTranslator.FromOle(QBColor(Color))
            .AppendText(Msg)
            .SelectionColor = Drawing.ColorTranslator.FromOle(QBColor(Color))
            .AppendText(Msg & vbNewLine)
        End With

    End Sub

 

    Public Sub AddText2(ByVal Msg As String, ByVal Color As Long)
        Dim s As String
        Dim C As Integer

        s = vbNewLine & Msg
        C = frmMainGame.txtChat2.SelectionStart
        frmMainGame.txtChat2.SelectionStart = Len(frmMainGame.txtChat2.Text)
        frmMainGame.txtChat2.SelectionColor = Drawing.ColorTranslator.FromOle(QBColor(Color))
        frmMainGame.txtChat2.SelectedText = s
        frmMainGame.txtChat2.SelectionStart = Len(frmMainGame.txtChat2.Text) - 1

    End Sub

 

both subs do nothing at all, stuff gets processed fine in the sub, but nothing shows >.<

help?

Link to comment
Share on other sites

Here is some code translated from C# from a school project I did. Not sure if it will help. Also what is Drawing.ColorTranslator.FromOle??? Never seen nor used it before...

Dim length As Integer = richTextBox.TextLength ' at end of text
richTextBox.AppendText(mystring)
richTextBox.SelectionStart = length
richTextBox.SelectionLength = mystring.Length
richTextBox.SelectionColor = Color.Red

 

Though I have no idea if it will work in vb.net as it was meant to be C#...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...