• Welcome to Valhalla Legends Archive.
 

Odd RTB position

Started by CrAz3D, February 22, 2005, 06:48 PM

Previous topic - Next topic

CrAz3D

I have my scrollbar set as just a vertical one.

But for some reason my text sometime shows up like this:


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?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

R.a.B.B.i.T

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

soLo.abUse

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

Warrior

You also dont create a new line :P
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

CrAz3D

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!
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Warrior

No he didn't

Never mind. Sorta silly to do it that way though.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

CrAz3D

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.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Blaze

Why do you talk about yourself in 3rd person? Its kind scary. :-\
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

CrAz3D

rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

R.a.B.B.i.T


l)ragon

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.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

K

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.