Ms access 长按或短按时的ms访问

Ms access 长按或短按时的ms访问,ms-access,vba,Ms Access,Vba,我想在输入框中显示一个字符:单击时显示点,长单击时显示破折号-。例如,按住鼠标左键2秒钟将显示破折号而不是圆点 我在双击时尝试了此操作,以下是我的代码: Private Sub input_Click() Me.input.Value = "." + Me.input.Value End Sub Private Sub input_DblClick(Cancel As Integer) Me.input.Value = "-" + Me.input.Value End Sub 这里的问题是,

我想在输入框中显示一个字符:单击时显示点
,长单击时显示破折号
-
。例如,按住鼠标左键2秒钟将显示破折号而不是圆点

我在双击时尝试了此操作,以下是我的代码:

Private Sub input_Click()
Me.input.Value = "." + Me.input.Value
End Sub

Private Sub input_DblClick(Cancel As Integer)
Me.input.Value = "-" + Me.input.Value
End Sub
这里的问题是,当我双击它将通过点击和显示点和破折号时,它应该只显示破折号

我想补充一点,我只需要用鼠标左键点击这个。没有键盘,没有右键点击

这就是为什么我的想法是使用点击点和双击破折号,或者点击和长点击


我的想法是在VBA上使用if语句,并检查是单击还是双击,而不使用双击事件。

在表单模块的标题中定义以下变量:

    Private isMouseKeyPreessed As Boolean
    Private timeMouseKeyPreessed  As Date
然后为名为
input
的文本框定义
MouseUp
MouseDown
事件(顺便说一下,这是个坏名字,因为
input
是保留字):


按下键,按下键……等一下,这是电报模拟器吗?@Jean-FrançoisCorbett是的@米奇麦我不能使用上下键,这里不会使用键盘。谢谢matemouse\u key\u down…,mouse\u key\u up…,谢谢@4dmonster,你真的是我问题的答案:)
    Private Sub input_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = acLeftButton Then
            isMouseKeyPreessed = True
            timeMouseKeyPreessed = Now
        End If
    End Sub

    Private Sub input_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim Delta  As Double
        Dim symbol As String

        If Button = acLeftButton Then
            isMouseKeyPreessed = False
            Delta = Now - timeMouseKeyPreessed
            If Delta > 0.00002 Then
                ' 0.00002 - is a value to tune up to get exactly 2 seconds
                ' it should be about
                ' cdbl(timeserial(0,0,2)-timeserial(0,0,0))
                symbol = "-"
            Else
                symbol = "."
            End If
            Me.input.Value = symbol & Me.input.Value
        End If

    End Sub