View Full Version : TextBox MouseDown and MouseUp Events
I am using Excel2003. I have a textbox in a form and wish to use the MouseDown and MouseUp events. Per the documentation, the syntax is:
Private Sub object_MouseDown( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)
Private Sub object_MouseUp( ByVal Button As fmButton, ByVal Shift As fmShiftState, ByVal X As Single, ByVal Y As Single)
fmButton and fmShiftState are undefined variables based on the libraries I am using (including MS Forms 2.0). It appears that there is a library I have not included.
Can someone tell me what that library is? Or if that is not the problem, what is?
Thanks
Paul_Hossler
10-04-2010, 03:42 PM
At least in 2010, the Object brower done not even seem to show fmButton and fmShiftState
I attached the values from the Help if it will help
Paul
At least in 2010, the Object brower done not even seem to show fmButton and fmShiftState
I attached the values from the Help if it will help
PaulThanks for the prompt reply. The text file you supplied is the source for the syntax statements in the original post. The object browser will only show those objects that are in the attached libraries. fmButton and fmShiftState are not shown in the Object Browser so they are not contained in any of the attached libraries. My question is in what library would I find those objects?
It seems strange that MouseUp and MouseDown are supported by several objects (at least as per the Object Browser) and documentation is contained in VBA Help; yet, critical passed parameters for the events are not found :banghead:
As a workaround, I could probably generate some dummy Type statements, but I would like to know what library is missing or if this is a bug.
Paul_Hossler
10-04-2010, 05:47 PM
Sorry - I usually let the VBE generate the event calls, and was thinking (or maybe not :doh:) that the fmButtonLeft etc. were defined as Enumerated (?) Constants
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
End Sub
This is different from the way the help file looks since it uses Integers.
Maybe you'll have to Enum your own
Option Explicit
Enum MouseButtons
fmButtonLeft = 1 'The left button was pressed.
fmButtonRight = 2 'The right button was pressed.
fmButtonMiddle = 4 'The middle button was pressed.
End Enum
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Select Case Button
Case fmButtonLeft
MsgBox "The left button was pressed"
Case fmButtonRight
MsgBox "The right button was pressed"
Case fmButtonMiddle
MsgBox "The middle button was pressed"
End Select
End Sub
But it is weird
Paul
Thanks, your approach works fine.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.