VB题~逃跑窗体~急

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:17:02
要求做一个逃跑窗体~~当鼠标靠近按钮时自动到另一个地方~~要求用到 MOVE和 随机数据~~~~求全部原代码~急

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