📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "滚动文本"
ClientHeight = 3465
ClientLeft = 60
ClientTop = 345
ClientWidth = 7515
LinkTopic = "Form1"
Picture = "Form1.frx":0000
ScaleHeight = 3465
ScaleWidth = 7515
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "循环滚动"
Height = 375
Left = 6480
TabIndex = 2
Top = 2760
Width = 975
End
Begin VB.CommandButton Command1
Caption = "滚动"
Height = 375
Left = 6480
TabIndex = 1
Top = 2280
Width = 975
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "可爱的小宝宝!"
BeginProperty Font
Name = "金桥简隶书"
Size = 36
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H008080FF&
Height = 750
Left = 2040
TabIndex = 0
Top = 360
Width = 5040
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim NewLeft, n As Long
NewLeft = Form1.ScaleWidth ' 设置标签框初始出现的位置
Do
Label1.Move NewLeft, 300 ' 移动到新位置
NewLeft = NewLeft - 50 ' 设置下次出现的位置
For n = 1 To 350 ' 利用循环实现暂停
DoEvents ' 将执行权交还操作系统
Next
Loop Until NewLeft <= -Label1.Width
End Sub
Private Sub Command2_Click()
Dim NewLeft, n As Long
NewLeft = Form1.ScaleWidth
Do While True
Label1.Move NewLeft, 300
NewLeft = NewLeft - 50
For n = 1 To 350
DoEvents
Next
' 若标签框最末端滚动出窗体视野区域,则重置初始位置
If NewLeft <= -Label1.Width Then
NewLeft = Form1.ScaleWidth
End If
Loop
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -