首页 /编程语言和算法/VB6/VBA/ASP
 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

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

 
全部回复(0)
首页 | 电脑版 |