Public Class Form1
Dim KeyState
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Boolean
Private Sub LogTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogTimer.Tick
For I = 1 To 255
KeyState = 0
KeyState = GetAsyncKeyState(I)
If KeyState = True Then
Me.txtLog.Text = Me.txtLog.Text & Chr(I)
End If
Next I
End Sub
End Class
只是一个失败: 我试图每十分之一秒(计时器)获得每个键的上/下状态,然后将任何按键添加到文本框中。
老实说,我看不出为什么这段代码不起作用。
答案 0 :(得分:2)
确保您确实告诉计时器从某处开始。根据我的经验,我总是不得不编写实际代码来告诉它开始,设计视图中的属性总是给我带来麻烦。