从Visual Basic .NET中的KeyDown获取ASCII字符代码

时间:2018-05-02 17:06:34

标签: vb.net

我试图创建一个Visual Basic .NET程序,当一个键关闭时,会显示一个按下了密钥代码的MsgBox:问题是该程序读了一个小写字母(例如,&#39 ; a')与相应的大写字母相同(例如,' A')。

这是VB .NET,Framework 4.6.1中的代码:

Public Class Form1
    Dim character As String
    Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
        MsgBox(e.KeyCode, MsgBoxStyle.Information)
    End Sub
End Class

如何以两个不同的数字读取小写字母和相应的大写字母?

1 个答案:

答案 0 :(得分:0)

说明汉斯评论:

Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    Dim msg As String = String.Format("You pressed: {0}", e.KeyChar.ToString)
    MessageBox.Show(msg)
End Sub