Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on February 22, 2005, 06:48 PM

Title: Odd RTB position
Post by: CrAz3D on February 22, 2005, 06:48 PM
I have my scrollbar set as just a vertical one.

But for some reason my text sometime shows up like this:
(http://68.35.184.146/xeno/images/weird1.gif)

Public Function Chat(ByVal TimeStamp As Boolean, ByVal NewLine As Boolean, ByVal TextColor As Long, ByVal text As String)
    If Len(Form1.RTB.text) > 20000 Then
        With Form1.RTB
            .Visible = False
            .SelStart = 0
            .SelLength = InStr(1, .text, vbLf, vbTextCompare)
            .SelText = vbNullString
            .Visible = True
        End With
    End If
   
    Form1.RTB.SelStart = Len(Form1.RTB.text)
       
    If NewLine = True And Form1.RTB.text <> "" Then
        Form1.RTB.SelText = Form1.RTB.SelText & vbCrLf
    End If
    If TimeStamp = True Then
        Form1.RTB.SelColor = &HC0C0&
        Form1.RTB.SelText = "[" & Time & "] "
    End If
       
    Form1.RTB.SelColor = TextColor
    Form1.RTB.SelText = Form1.RTB.SelText & text
    Form1.RTB.SelStart = Len(Form1.RTB.text)
   
End Function


Any suggestions?
Title: Re: Odd RTB position
Post by: R.a.B.B.i.T on February 22, 2005, 07:20 PM
Public Function Chat(ByVal TimeStamp As Boolean, ByVal NewLine As Boolean, ByVal TextColor As Long, ByVal text As String)
    If Len(Form1.RTB.text) > 20000 Then
        With Form1.RTB
            .Visible = False
            .SelStart = 0
            .SelLength = InStr(1, .text, vbLf, vbTextCompare)
            .SelText = vbNullString
            .Visible = True
        End With
    End If
   
    Form1.RTB.SelStart = Len(Form1.RTB.text)
       
    If NewLine = True And Form1.RTB.text <> "" Then
        Form1.RTB.SelText = Form1.RTB.SelText & vbCrLf
    End If
    If TimeStamp = True Then
        Form1.RTB.SelColor = &HC0C0&
        Form1.RTB.SelText = "[" & Time & "] "
    End If
       
    Form1.RTB.SelStart = Len(Form1.RTB.Text)
    Form1.RTB.SelLength = Len(text)
    Form1.RTB.SelColor = TextColor
    Form1.RTB.SelText = Form1.RTB.SelText & text
    Form1.RTB.SelStart = Len(Form1.RTB.text)
   
End Function
Title: Re: Odd RTB position
Post by: soLo.abUse on February 22, 2005, 08:05 PM
That code is redundant.  There's no point to set the start position at the end of the function and then the next time it's called reset it again!



Call AppendText(ChatOutput, vbGreen, "This is a ", vbRed, "test!" & vbCrLf)

Sub AppendText(ByVal RichEdit As RichTextBox, ParamArray OutputData() As Variant)

    With RichEdit
        .SelStart = Len(.Text)
        .SelColor = vbBlack
        .SelText = "[Timestamp] "

        Dim I As Integer
       
        For I = LBound(OutputData) To UBound(OutputData) Step 2
            .SelColor = CLng(OutputData(I))
            .SelText = CStr(OutputData(I + 1))
        Next I

    End With

End Sub
Title: Re: Odd RTB position
Post by: Warrior on February 23, 2005, 02:57 PM
You also dont create a new line :P
Title: Re: Odd RTB position
Post by: CrAz3D on February 23, 2005, 04:27 PM
He created he new line by adding vbcrlf into the text he was adding.

I used a modified version of what lobo gave me & what I add (from Fr0z3N?) & now it all seems to work.

THANKS!
Title: Re: Odd RTB position
Post by: Warrior on February 23, 2005, 04:32 PM
No he didn't

Never mind. Sorta silly to do it that way though.
Title: Re: Odd RTB position
Post by: CrAz3D on February 23, 2005, 07:01 PM
Quote from: Warrior on February 23, 2005, 04:32 PM
No he didn't

Never mind. Sorta silly to do it that way though.
Word, that is why CrAz3D didn't use his exact code.
Title: Re: Odd RTB position
Post by: Blaze on February 23, 2005, 07:56 PM
Why do you talk about yourself in 3rd person? Its kind scary. :-\
Title: Re: Odd RTB position
Post by: CrAz3D on February 23, 2005, 08:31 PM
Cause I love me?
Title: Re: Odd RTB position
Post by: R.a.B.B.i.T on February 24, 2005, 03:42 PM
Quote from: CrAz3D on February 23, 2005, 08:31 PM
Cause I love me?
Cause CrAz3D loves himself.*
Title: Re: Odd RTB position
Post by: l)ragon on February 26, 2005, 02:05 PM
Quote from: CrAz3D on February 23, 2005, 04:27 PM
He created he new line by adding vbcrlf into the text he was adding.

I used a modified version of what lobo gave me & what I add (from Fr0z3N?) & now it all seems to work.

THANKS!
You can't better yourself from copy and paste tactics lol, do you know what the problem was and how they fixed it.

From the screen shot it looks to me like somone forgot to turn on the wordwrap.
Title: Re: Odd RTB position
Post by: K on March 01, 2005, 11:16 PM
Quote from: soLo.abUse on February 22, 2005, 08:05 PM
That code is redundant. There's no point to set the start position at the end of the function and then the next time it's called reset it again!

Setting the start position at the beginning of the function assures that the insertion point really is at the end of the text.  Setting it at the end makes sure the rich text box scrolls down to show the new lines if they are off the visible area.