Functionkeyを設定する方法?


かなた  2003-10-22 17:01:25  No: 79915

FunctionkeyをButtonに割り当てたいのですが、どのようにすれば
よいのでしょうか?ご教授ください。


Say  2003-10-22 18:11:09  No: 79916

こういうこと?

Option Explicit
Private Sub PushFKey(pKeyCode As Integer)
    Select Case pKeyCode
        Case vbKeyF1
            MsgBox "F1 Pushed!!"
        Case vbKeyF2
            MsgBox "F2 Pushed!!"
        Case Else
            MsgBox "Any Key Pushed!!"
    End Select
End Sub
Private Sub Command1_Click(Index As Integer)
    Call PushFKey(Index + vbKeyF1)
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyF1, vbKeyF2, vbKeyF3, vbKeyF4, _
             vbKeyF5, vbKeyF6, vbKeyF7, vbKeyF8, _
             vbKeyF9, vbKeyF10, vbKeyF11, vbKeyF12
             Call PushFKey(KeyCode)
    End Select
End Sub

Private Sub Form_Load()
    Dim i As Long
    Me.KeyPreview = True
    With Command1(0)
        .Left = 120
        .Top = 120
        .Height = 495
        .Width = 615
        .Caption = "F1"
    End With
    For i = 1 To 11
        Load Command1(i)
        With Command1(i)
            .Left = Command1(i - 1).Left + Command1(i - 1).Width
            .Caption = "F" & CStr(i + 1)
            .Visible = True
        End With
    Next
End Sub


※返信する前に利用規約をご確認ください。

※Google reCAPTCHA認証からCloudflare Turnstile認証へ変更しました。






  このエントリーをはてなブックマークに追加