Valhalla Legends Forums Archive | Visual Basic Programming | Odd RTB position

AuthorMessageTime
CrAz3D
I have my scrollbar set as just a vertical one.

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

[code]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[/code]

Any suggestions?
February 23, 2005, 12:48 AM
R.a.B.B.i.T
[code]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[/code]
February 23, 2005, 1:20 AM
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!

[code]

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
[/code]
February 23, 2005, 2:05 AM
Quarantine
You also dont create a new line :P
February 23, 2005, 8:57 PM
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!
February 23, 2005, 10:27 PM
Quarantine
[s]No he didn't[/s]

Never mind. Sorta silly to do it that way though.
February 23, 2005, 10:32 PM
CrAz3D
[quote author=Warrior link=topic=10676.msg101260#msg101260 date=1109197964]
[s]No he didn't[/s]

Never mind. Sorta silly to do it that way though.
[/quote]Word, that is why CrAz3D didn't use his exact code.
February 24, 2005, 1:01 AM
KkBlazekK
Why do you talk about yourself in 3rd person? Its kind scary. :-\
February 24, 2005, 1:56 AM
CrAz3D
Cause I love me?
February 24, 2005, 2:31 AM
R.a.B.B.i.T
[quote author=CrAz3D link=topic=10676.msg101310#msg101310 date=1109212267]
Cause I love me?
[/quote]Cause CrAz3D loves himself.*
February 24, 2005, 9:42 PM
dRAgoN
[quote author=CrAz3D link=topic=10676.msg101252#msg101252 date=1109197671]
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!
[/quote]
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.
February 26, 2005, 8:05 PM
K
[quote author=soLo.abUse link=topic=10676.msg101125#msg101125 date=1109124349]
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!
[/quote]

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.
March 2, 2005, 5:16 AM

Search