返回列表 上一主題 發帖

[發問] 如何放入form

[發問] 如何放入form

請教大大,以下如何放入form?試了還是出不到效果...
The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

To try the example, add the following event procedure to a form that contains a label named Coordinates:

Private Sub Detail_MouseMove(Button As Integer, _
     Shift As Integer, X As Single, Y As Single)
    Dim intShiftDown As Integer, intLeftButton As Integer

    Me!Coordinates.Caption = X & ", " & Y
    ' Use bit masks to determine state of
    ' SHIFT key and left button.
    intShiftDown = Shift And acShiftMask
    intLeftButton = Button And acLeftButton
    ' Check that SHIFT key and left button
    ' are both pressed.
    If intShiftDown And intLeftButton > 0 Then
        MsgBox "Shift key and left mouse button were pressed."
    End If
End Sub

回復 4# 暗黑


    成了!謝謝大大!

TOP

改用這一個
我沒改程式碼,還是跟上次回覆一樣,只是更改妳的事件驅動
另...我是用 程式編輯窗視上的事件挑選器
我測試過  滑鼠的坐標會在  label 上 顯示(其他沒試),有問題在說吧
  1. Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)



  2.     Dim intShiftDown As Integer, intLeftButton As Integer

  3.     Me!Coordinates.Caption = X & ", " & Y
  4.     ' Use bit masks to determine state of
  5.     ' SHIFT key and left button.
  6.     intShiftDown = Shift And acShiftMask
  7.     intLeftButton = Button And acLeftButton
  8.     ' Check that SHIFT key and left button
  9.     ' are both pressed.
  10.     If intShiftDown And intLeftButton > 0 Then
  11.         MsgBox "Shift key and left mouse button were pressed."
  12.     End If


  13. End Sub
複製代碼
是學程式而不是要程式,是進步的基礎

TOP

回復 2# 暗黑


    謝謝大大!請指教那裡錯...
滑鼠座標.rar (11.22 KB)

TOP

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Detail   改成  你的表單名稱   如:  UserForm
是學程式而不是要程式,是進步的基礎

TOP

        靜思自在 : 願要大、志要堅、氣要柔、心要細。
返回列表 上一主題