Board logo

標題: [發問] 如何放入form [打印本頁]

作者: cdkee    時間: 2010-11-10 19:14     標題: 如何放入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
作者: 暗黑    時間: 2010-11-11 09:04

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

Detail   改成  你的表單名稱   如:  UserForm
作者: cdkee    時間: 2010-11-11 12:40

回復 2# 暗黑


    謝謝大大!請指教那裡錯...
[attach]3573[/attach]
作者: 暗黑    時間: 2010-11-12 08:14

改用這一個
我沒改程式碼,還是跟上次回覆一樣,只是更改妳的事件驅動
另...我是用 程式編輯窗視上的事件挑選器
我測試過  滑鼠的坐標會在  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
複製代碼

作者: cdkee    時間: 2010-11-12 13:01

回復 4# 暗黑


    成了!謝謝大大!




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)