-
This is what happens:
say this is the chat log:
-
Me: hey
you: sup?
me: Nothing much, you?
you: same
-
me: sounds fun
you: indeed...
me: well my textbox glitches
Ok, that's all nice, say the height is only 4 lines high
but when I add text and I have the selstart = len(text) it'll flash to the top of the box so I can very briefly see the top 4 lines then it goes to the bottom. I havn't experienced this with other programs, aol, etc.
I need something to make the scroll bar stay in the same place.
-
The reason for this flicker is that you are changing the Text property. When you do that the caret is moved to the first position in the TextBox. Use the SelText property instead:
Code:
With RichTextBox1
.SelStart = Len(.Text)
.SelText = vbCrLf & "The New Text To Add"
End With
Good luck!
-
Your code worked great except that the SelText blocks some characters. Chr$(0) for example, if anything comes after it it won't appear.
Anyway to fix this?
-
The reason chr$(0) is blocked is because in C and C++ a null char means end of string.
Why would you like to send a null char after all?
-
It has a coloring code like IRC where the first few characters format the text, bold, italic, colors, etc.
-
Further more...
That's why I switched to a RTB instead of a regular textbox.
-
Use the SelColor, SelBold, SelItalic, SelUnderline and so on to set these properties before you use the SelText property to set the text.
Code:
With RichTextBox1
.SelStart = Len(.Text)
.SelColor = vbRed 'or whatever
.SelBold = True
.SelText = "Here comes some text in red and bold font"
End With
Good luck!
-
I'm not sure if this will work, i havn't tried it on a rtbox, but it got rid of glitches in a flexgrid control.
before you assign the new text to the rich text box can you just set the visible property of the box to false, and then set it to true after you add the text?
maybe maybe who knows...