|
先在表單上拉一個 command 以下是程式碼
研究看看吧
希望對妳有幫助 xd
------------------以下為程式碼------------------
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'當滑鼠在 按鍵Command1 裡面移動時會執行下列程式碼
'X 是存放滑鼠的 x 軸作標
'Y 是存放滑鼠的 y 軸作標
'Command1.Top 存放 按鍵Command1 左緣與 表單Form1 左緣之間的距離
'Command1.Left 存放 按鍵Command1 上緣與 表單Form1 上緣之間的距離
Command1.Top = Command1.Top + X + X + X
'如果當 按鍵Command1 高度位置超過 表單Form1
If Command1.Top + Command1.Height > Form1.Height Then
Command1.Top = 0
End If
Command1.Left = Command1.Left + Y + Y + Y
'如果當 按鍵Command1 距離左邊位置超過 表單Form1
If Command1.Left + Command1.Width > Form1.Width Then
Command1.Left = 0
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "嫩鬼妳點不到我"
End Sub |
|