查看: 4  |  回复: 0
  VB6 好用的Log显示,子程序 s_show(strW$)
楼主
发表于 昨天 20:27

新建From1(窗体),新建txtChat(TextBox,MultiLine选True,ScrollBars选3),Command1(按钮CommandButton),代码:

Private Sub Command1_Click()
    s_show Time
End Sub

Private Sub s_show(strW$)
    With txtChat
        If Len(.Text) > 2000 Then .Text = ""    '大于2000就清空
        .SelStart = Len(.Text)    '从最下方开始
        .SelText = strW & vbCrLf    '每行加个回车
        .SelStart = Len(.Text)    '滚动条到最下面
    End With
End Sub

不断点击Command1可以看到效果:

20:27:58
20:27:59
20:28:00
20:28:01
20:28:01
20:28:02
20:28:03

显示的时间在尾部增加并且滚动条会到最下面。

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2025 MaNongKu.com