vb 滚动条控制图片移动快慢按钮开始停止
2个回答
展开全部
简单!
添加两个Picturebox ,Picture2放在Picture1里面!
添加一个时间timer和两个textbox ,text1是时间速度,text2是移动距离!
再加三个commandbutton,为command1.command2.command3
然后复制代码自己调试! Picture1和Picture2的边框去掉然后图片自己加!
Private Sub Command1_Click()
Timer1.Interval = Abs(Text1.Text)
End Sub
Private Sub Command2_Click()
Picture2.Left = -Picture1.Width
End Sub
Private Sub Command3_Click()
If Command3.Caption = "开始" Then
Timer1.Enabled = True
Command3.Caption = "停止"
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "变速"
Command2.Caption = "重来"
Command3.Caption = "开始"
Picture2.Width = 300
Picture2.Left = -Picture2.Width
End Sub
Private Sub Timer1_Timer()
Picture2.Left = Picture2.Left + Abs(Text2.Text)
If Picture2.Left >= Picture1.Width Then Picture2.Left = -Picture2.Width
End Sub
添加两个Picturebox ,Picture2放在Picture1里面!
添加一个时间timer和两个textbox ,text1是时间速度,text2是移动距离!
再加三个commandbutton,为command1.command2.command3
然后复制代码自己调试! Picture1和Picture2的边框去掉然后图片自己加!
Private Sub Command1_Click()
Timer1.Interval = Abs(Text1.Text)
End Sub
Private Sub Command2_Click()
Picture2.Left = -Picture1.Width
End Sub
Private Sub Command3_Click()
If Command3.Caption = "开始" Then
Timer1.Enabled = True
Command3.Caption = "停止"
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "变速"
Command2.Caption = "重来"
Command3.Caption = "开始"
Picture2.Width = 300
Picture2.Left = -Picture2.Width
End Sub
Private Sub Timer1_Timer()
Picture2.Left = Picture2.Left + Abs(Text2.Text)
If Picture2.Left >= Picture1.Width Then Picture2.Left = -Picture2.Width
End Sub
展开全部
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
HScroll1.Max = 499
HScroll1.Min = 0
HScroll1.Value = 0
HScroll1.LargeChange = 100
HScroll1.SmallChange = 50
End Sub
Private Sub HScroll1_Change()
Timer1.Interval = 500 - HScroll1.Value
End Sub
Private Sub Timer1_Timer()
If Picture1.Left + Picture1.Width < Me.Width Then
Picture1.Left = Picture1.Left + 10
End If
End Sub
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500
HScroll1.Max = 499
HScroll1.Min = 0
HScroll1.Value = 0
HScroll1.LargeChange = 100
HScroll1.SmallChange = 50
End Sub
Private Sub HScroll1_Change()
Timer1.Interval = 500 - HScroll1.Value
End Sub
Private Sub Timer1_Timer()
If Picture1.Left + Picture1.Width < Me.Width Then
Picture1.Left = Picture1.Left + 10
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询