求高手指点,vb编程字母移动可以通过滚动条调节滚动速度,两个单选按钮控制左右移动方向。不胜感激!
1个回答
展开全部
Dim x As Long
Private Sub Form_Load()
Option1.Value = 1
HScroll1.Max = 500
HScroll1.Min = 0
HScroll1.SmallChange = 10
HScroll1.LargeChange = 50
Timer1.Interval = 100
Label1.Caption = "A"
End Sub
Private Sub HScroll1_Change()
Dim s As Integer
s = IIf(x = 0, 1, Sgn(x))
x = HScroll1.Value * s
End Sub
Private Sub Option1_Click()
x = Abs(x)
End Sub
Private Sub Option2_Click()
x = -x
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + x
If Label1.Left <= 0 Then x = Abs(x)
If Label1.Left + Label1.Width > Me.Width Then x = -x
End Sub
Private Sub Form_Load()
Option1.Value = 1
HScroll1.Max = 500
HScroll1.Min = 0
HScroll1.SmallChange = 10
HScroll1.LargeChange = 50
Timer1.Interval = 100
Label1.Caption = "A"
End Sub
Private Sub HScroll1_Change()
Dim s As Integer
s = IIf(x = 0, 1, Sgn(x))
x = HScroll1.Value * s
End Sub
Private Sub Option1_Click()
x = Abs(x)
End Sub
Private Sub Option2_Click()
x = -x
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + x
If Label1.Left <= 0 Then x = Abs(x)
If Label1.Left + Label1.Width > Me.Width Then x = -x
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询