2个回答
展开全部
Option Explicit
'
'字幕滚动程序
'使用控件:一个Label控件,一个Text控件,一个Timer控件,一个HScrollbar控件,2个Option控件(单选按钮)
'要滚动的字幕在Text1内输入
'
'
Private Sub Form_Load()
HScroll1.Max = 10
HScroll1.Min = 1
HScroll1.Value = 1
HScroll1.SmallChange = 1
HScroll1.LargeChange = 1
Option1.Value = True
Option1.Caption = "方式一"
Option2.Caption = "方式二"
Timer1.Enabled = True
Timer1.Interval = 100
Text1.Text = "利用时钟和滚动条设计一个字幕滚动程序,并且可以控制滚动的快慢。"
Label1.Caption = Text1.Text & Space(Label1.Width \ 96)
End Sub
Private Sub HScroll1_Change()
Timer1.Interval = HScroll1.Value * 100
End Sub
Private Sub Option1_Click()
Label1.Caption = Text1.Text & Space(Label1.Width \ 96)
End Sub
Private Sub Option2_Click()
Label1.Caption = Text1.Text
End Sub
Private Sub Timer1_Timer()
If Asc(Left(Label1.Caption, 1)) > 0 Then
Label1.Caption = Mid(Label1.Caption, 3, Len(Label1.Caption) - 2) & Left(Label1.Caption, 2)
Else
Label1.Caption = Mid(Label1.Caption, 2, Len(Label1.Caption) - 1) & Left(Label1.Caption, 1)
End If
End Sub
'
'字幕滚动程序
'使用控件:一个Label控件,一个Text控件,一个Timer控件,一个HScrollbar控件,2个Option控件(单选按钮)
'要滚动的字幕在Text1内输入
'
'
Private Sub Form_Load()
HScroll1.Max = 10
HScroll1.Min = 1
HScroll1.Value = 1
HScroll1.SmallChange = 1
HScroll1.LargeChange = 1
Option1.Value = True
Option1.Caption = "方式一"
Option2.Caption = "方式二"
Timer1.Enabled = True
Timer1.Interval = 100
Text1.Text = "利用时钟和滚动条设计一个字幕滚动程序,并且可以控制滚动的快慢。"
Label1.Caption = Text1.Text & Space(Label1.Width \ 96)
End Sub
Private Sub HScroll1_Change()
Timer1.Interval = HScroll1.Value * 100
End Sub
Private Sub Option1_Click()
Label1.Caption = Text1.Text & Space(Label1.Width \ 96)
End Sub
Private Sub Option2_Click()
Label1.Caption = Text1.Text
End Sub
Private Sub Timer1_Timer()
If Asc(Left(Label1.Caption, 1)) > 0 Then
Label1.Caption = Mid(Label1.Caption, 3, Len(Label1.Caption) - 2) & Left(Label1.Caption, 2)
Else
Label1.Caption = Mid(Label1.Caption, 2, Len(Label1.Caption) - 1) & Left(Label1.Caption, 1)
End If
End Sub
展开全部
需要控件三个:标签label1、计时器timer1、水平滚动条hscroll1。全部代码如下:
Dim Bujinliang As Single
Private Sub Form_Load()
s = "我在滚动……"
Label1 = s
Me.FontSize = 24
Label1.FontSize = 24
Label1.Width = TextWidth(s)
Label1.Height = TextHeight(s)
HScroll1.Max = 1000
HScroll1.Min = 100
HScroll1.LargeChange = 100
HScroll1.SmallChange = 100
Timer1.Interval = 100
End Sub
Private Sub HScroll1_Change()
Bujinliang = HScroll1.Value
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left - Bujinliang
If Label1.Left < -Label1.Width Then Label1.Left = Width
End Sub
Dim Bujinliang As Single
Private Sub Form_Load()
s = "我在滚动……"
Label1 = s
Me.FontSize = 24
Label1.FontSize = 24
Label1.Width = TextWidth(s)
Label1.Height = TextHeight(s)
HScroll1.Max = 1000
HScroll1.Min = 100
HScroll1.LargeChange = 100
HScroll1.SmallChange = 100
Timer1.Interval = 100
End Sub
Private Sub HScroll1_Change()
Bujinliang = HScroll1.Value
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left - Bujinliang
If Label1.Left < -Label1.Width Then Label1.Left = Width
End Sub
参考资料: 自己写的
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询