if wParam=13  then
      lable1.caption="HELLO"
end if这是按了1次回车后的过程
我要问的是如果连续2次按了回车呢(就是连击回车)? 改如何表示

解决方案 »

  1.   

    楼主的意思大概是:很快的按两次《Enter》键
    和 按两次《Enter》键 是不一样的吧如果是这样的话,我有个笨办法
    可以用两个Timer控件来解决这个问题
    Timer控件的精度是毫秒级的
      

  2.   

    不知樓主按的是哪個控件Option ExplicitDim nEnter As IntegerPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
       If KeyCode = 13 Then
          nEnter = nEnter + 1
          If nEnter = 2 Then
             Label1.Caption = "找死啊,這樣子按"
             nEnter = 0
          End If
       Else
         nEnter = 0
         Label1.Caption = "不罵你不痛快"
       End If
       
    End Sub
      

  3.   

    myxmouse(小老鼠)我的意思就是这个
      

  4.   

    樓主是如此意思啊
    如果只考慮雙擊而不用考慮單擊的話不用計時器還是可以,如果要考慮單擊的情況那肯定得用計時器'以下放於模組中:Option ExplicitType SYSTEMTIME    wYear As Integer    wMonth As Integer    wDayOfWeek As Integer    wDay As Integer    wHour As Integer    wMinute As Integer    wSecond As Integer    wMilliseconds As IntegerEnd Type'↓在一個SYSTEMTIME中載入當前系統時間,這個時間採用的是"協同世界時間"(即UTC,也叫做GMT)格式
    Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)'↓設置連續兩次滑鼠單擊之間能使系統認為是雙擊事件的間隔時間
    Public Declare Function SetDoubleClickTime Lib "user32" (ByVal wCount As Long) As Long'↓判斷連續兩次滑鼠單擊之間會被處理成雙擊事件的間隔時間
    Declare Function GetDoubleClickTime Lib "user32" () As LongPublic Function GetMS()
       Dim lpSystem As SYSTEMTIME
       GetSystemTime lpSystem
       Dim YMDHS As String
       Dim Ms As String
       
       YMDHS = lpSystem.wYear & "/" & lpSystem.wMonth & "/" & lpSystem.wDay & " " & lpSystem.wHour & ":" & lpSystem.wMinute & ":" & lpSystem.wSecond
       Ms = Format(lpSystem.wMilliseconds, "000")
       
       GetMS = Format(YMDHS, "YYYYMMDDHHMMSS") & Ms
    End Function'以下放於FORM中:
    Option Explicit
    Dim nDoubleClickTime As Long
    Dim nEnter As Integer
    Dim sTime1 As String
    Dim sTime2 As String
    Private Sub Form_Load()
       nDoubleClickTime = GetDoubleClickTime
       Debug.Print "nDoubleClickTime: " & nDoubleClickTime
    End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
       Dim CurTime As String
       If KeyCode = 13 Then
          CurTime = GetMS
          nEnter = nEnter + 1
          If nEnter = 2 Then
             sTime2 = CurTime
             If Val(sTime2) - Val(sTime1) <= nDoubleClickTime Then '如果在雙擊時間間隔內
                Label1.Caption = "雙擊"
                
                nEnter = 0
             Else
                Label1.Caption = ""
                sTime1 = CurTime
                nEnter = 1
             End If
          Else
             sTime1 = CurTime
             Label1.Caption = ""
          End If
       Else
         nEnter = 0
         Label1.Caption = ""
       End If
    End Sub粗略的測試了一下,自己再調試調試
      

  5.   

    用一个timer是比较占内存的,因为它必须一直开着
    但是用两个的话就不占了