如何从另一个 Sub 使用 KeyEventArgs 调用 Sub

问题描述 投票:0回答:1

我有两个潜艇

Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown

Private Sub Form1_KeyPressCaps(ByVal key As Object, e As KeyEventArgs) Handles Me.KeyDown

    If e.KeyCode = Keys.CapsLock Then
        If keyStCL = True Then

            checkbutton_caps.Checked = False
            checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_off
            'Image.FromFile("resources\btn_ico_caps_off.png")
            keyStCL = False

        ElseIf keyStCL = False Then
            checkbutton_caps.Checked = True
            checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_on
            'Image.FromFile("resources\btn_ico_caps_on.png")
            keyStCL = True

        End If
    End If
End Sub

我想从 kbHook_KeyDown 调用 Form1_KeyPressCaps。我该怎么做。
我试过这个:

Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
    Call Form1_KeyPressCaps(Key, New KeyEventArgs)
End Sub

但它不起作用。我收到错误:

未为“Public Sub New(keyData As System.Windows.Forms.Keys)”的参数“keyData”指定参数。

vb.net events call keyboard-events keyevent
1个回答
1
投票
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
    Call Form1_KeyPressCaps(Key, New KeyEventArgs(Key))
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.