如何在vb .net中编写退格和空格的代码

时间:2016-03-17 05:54:35

标签: vb.net

我正在使用图像编写虚拟键盘,当我按下键时它会显示图像但是我无法编码空间和退格...

Dim myDir As String = "C:\Users\ASUBUSU\Desktop\keyboard\java pgm\"
Dim img As Image = Image.FromFile(myDir & "sna.png")
Dim orgData = Clipboard.GetDataObject
Clipboard.SetImage(img)
Me.RichTextBox1.Paste()
Clipboard.SetDataObject(orgData)

如何编写空间和退格代码。

2 个答案:

答案 0 :(得分:0)

查看按键/按键/按键事件。

    Private Sub form_KeyPress(sender As System.Object, e As System.EventArgs) Handles Me.KeyPress
        Dim tmp As System.Windows.Forms.KeyPressEventArgs = e
        'Example for "Enter" key
        If tmp.KeyChar = ChrW(Keys.Enter) Then
            ' do something
        End If
    End Sub

答案 1 :(得分:-1)

If e.KeyChar = Convert.ToChar(8) Then 

OR

If e.KeyChar = Convert.ToChar(Keys.Back) Then

等等。