Post Routine

By | 2008-03-03

Makes a multi-line textbox into a scrolling textbox, chat-style.

Usage

post frmLogging.text1, "Text to Post"

Side Effects

Constant MAXCHARS must be declared at the top of the module. Do not exceed 50000 for MAXCHARS.

Const MAXCHARS = 5000
Public Sub Post(tbxEditBox As TextBox, sNewText As String)
  sNewText = sNewText & vbCrLf
  With tbxEditBox
    If Len(sNewText) + Len(.Text) > MAXCHARS Then
      ''Scroll some text off the top to make more room
      .Text = Mid$(.Text, InStr(100 + Len(sNewText), .Text, vbCrLf) + 2)
    End If
    .SelStart = Len(.Text)
    .SelText = sNewText
  End With
  DoEvents
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.