'首先建立一个窗体,在其上放置两个TIMER,一个按钮、一个文本框。将文本框的MultiLine属性设为True,ScrollBars属性设为3-Both。
'然后输入以下代码:
Const EM_LINESCROLL = &HB6
Private Declare Function SendMessage Lib "User32" Alias _
"SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Private Sub Form_Load()
Dim intLineIndex As Integer, intWordIndex As Integer
'Initialize Text1.
Text1.Font = "Courier New"
Text1.Text = ""
For intLineIndex = 1 To 50 'Add 25 lines of text.
Text1.Text = Text1.Text & "Line" & Str$(intLineIndex)
For intWordIndex = 1 To 30 'Make each line 12 words
'long.
Text1.Text = Text1.Text & " Word" & Str$(intWordIndex)
Next intWordIndex
Text1.Text = Text1.Text & vbCrLf
Next intLineIndex
Timer1.Enabled = True
Timer2.Enabled = False
Timer1.Interval = 1000
Timer2.Interval = 1000
End Sub
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
Timer2.Enabled = Not Timer2.Enabled
End Sub
Private Sub Timer1_Timer()
SendMessage Text1.hWnd, EM_LINESCROLL, 0, 3
End Sub
Private Sub Timer2_Timer()
SendMessage Text1.hWnd, EM_LINESCROLL, 3, 0&
End Sub