0

ユーザーが任意のキーを入力するとそこに表示される RichTextBox があります。「。」のGetAsyncKeyStateを試しました。および「-」などは機能しませんが、AZ と 0-9 は正しく機能します。

Private Sub tmrKeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrKeys.Tick
    Dim result As Integer
    Dim key As String = Nothing
    Dim p As Boolean = CBool(GetAsyncKeyState(Keys.P))
    Dim i As Integer
    Dim dec As Boolean = CBool(GetAsyncKeyState(Keys.Decimal))
    Dim subtract As Boolean = CBool(GetAsyncKeyState(Keys.Subtract))
    Dim add As Boolean = CBool(GetAsyncKeyState(Keys.Add))



    Try
        For i = 2 To 90
            result = 0
            result = GetAsyncKeyState(i)
            If result = -32767 Then
                key = Chr(i)
                If i = 13 Then key = vbNewLine

                Exit For
            End If
        Next i

        If key <> Nothing Then
            If My.Computer.Keyboard.ShiftKeyDown OrElse My.Computer.Keyboard.CapsLock Then
                txtlogs.Text &= key.ToUpper
            ElseIf key = vbBack Then
                If txtlogs.TextLength > 0 Then
                    txtlogs.Text = txtlogs.Text.Remove(txtlogs.TextLength - 1)
                End If
            ElseIf My.Computer.Keyboard.CtrlKeyDown Then
                txtlogs.Text &= " -[CTRL+" & key & "]"
            ElseIf subtract = True Then
                txtlogs.Text &= "-"
            ElseIf My.Computer.Keyboard.ShiftKeyDown AndAlso subtract = True Then
                txtlogs.Text &= "_"
            ElseIf dec = True Then
                txtlogs.Text &= "."
            Else
                txtlogs.Text &= key.ToLower
            End If
        End If

ユーザーがキーボードで 10 進数を押したときに、RichTextBox に "." が追加されます。テキストなどに

事前に助けてくれてありがとう

4

1 に答える 1