Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF3 Then
        执行你绑定按钮的事件
    End If
End Sub

解决方案 »

  1.   

    form_load中添加
    SendMessage(me.hwnd,WM_SETHOTKEY,VK_F3 )
      

  2.   

    请问westwin(浪子西) :这样的话,怎么能表示热键是和按钮控件绑定在一起的呢?
      

  3.   

    .sorry,没看清题目,我以为是和窗体绑定的?帮你Up
      

  4.   

    设置窗体的keypreview属性为true,例子代码如下Option ExplicitPrivate Sub Command1_Click()
    MsgBox "hello"
    End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF3
            Command1_Click
    End Select
    End Sub
      

  5.   

    添加一个timer 和 command1Option Explicit
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    '判断函数调用时指定虚拟键的状态
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    '查找与指定文件关联在一起的程序的文件名
    Dim HyperJump
    Private Sub Command1_Click()
    HyperJump = ShellExecute(0&, vbNullString, "http://sun.ccthtf.com.cn/", vbNullString, vbNullString, vbNormalFocus)
    End Sub
    Private Sub Form_Load()
    With Timer1
    .Interval = 1
    End With
    End Sub
    Private Sub Timer1_Timer()
    If MyHotKey(vbKeyF3) Then Command1_Click
    End Sub
    Private Function MyHotKey(vKeyCode) As Boolean
    MyHotKey = (GetAsyncKeyState(vKeyCode) < 0)
    End Function