VB怎么让标签不断的上下左右移动
发布网友
发布时间:2022-05-06 02:47
我来回答
共3个回答
热心网友
时间:2022-06-28 13:19
使用timer空间使标签的top属性变大或变小,标签会往下或往上移动,使标签的left属性变大或变小,标签会往右或往左移动,同时使用,标签就会像DVD那样了。
具体怎么移动完全取决于你的想法,没有固定的代码。
热心网友
时间:2022-06-28 13:19
我写了个随机移动的标签不知道符合不符合你的要求。
Dim l, t
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer1.Interval = 1000
Randomize
l = Int(Rnd * 5000 + 0)
t = Int(Rnd * 2000 + 0)
Label1.Left = Me.Left + l
Label1.Top = Me.Top + t
End Sub
热心网友
时间:2022-06-28 13:20
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Left = Int(Rnd * Me.ScaleWidth)
Label1.Top = Int(Rnd * Me.ScaleHeight)
End Sub