VB题~逃跑窗体~急
来源:百度知道 编辑:UC知道 时间:2024/05/21 16:17:02
Private Sub Form_Load()
Command1.Enabled = False
Command1.Caption = "来点啊"
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Command1.Left Then Exit Sub
If Y < Command1.Top Then Exit Sub
If X > Command1.Left + Command1.Width Then Exit Sub
If Y > Command1.Top + Command1.Height Then Exit Sub
Command1.Left = Int((Form1.ScaleHeight - Command1.Width) * Rnd)
Command1.Top = Int((Form1.ScaleHeight - Command1.Height) * Rnd)
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Move Int((Form1.Width + 1) * Rnd) - Command1.Width, Int(Rnd * (Form1.Height)) - Command1.Height
End Sub
是 靠近按钮 嘛,所以应该是form的mousemove事件吧?
判断一下靠近按钮时就改变按钮的left和top属性!
需要添加command1,代码:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Random