很简单的问题,硬是让我弄复杂了,各位请进!
我要把键盘击键转换成字符,用到系统API:ToUnicode
代码简化如下:
Private Declare Function ToUnicode Lib "user32.dll" (ByVal wVirtKey As Int32, ByVal wScanCode As Int32,
ByRef lpKeyState As Byte, ByVal pwszBuff As StringBuilder,
ByVal cchBuff As Int32, ByVal wFlags As Int32) As Int32
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim b As New StringBuilder(" ", 1)
ToUnicode(191, 0, 0, b, 1, 0)'191是字符"/"
Debug.Print(b.ToString)
Dim t As String = ""'如果没有这句,则上面的代码是正确的,否则变量b的值将为空!
End Sub