Windows Forms - Teclado

A app 31 é um teste de teclado completo

Module Teclado

Aceitando as teclas numéricas hexadecimais

    'o TextBox só aceitará caracteres Hexadecimais (0 a F)
    'Colocar no evento Keypress to TextBox
    'Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    ' If Char.IsLetterOrDigit(e.KeyChar) Then
    ' Select Case UCase(e.KeyChar)
    ' Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
    ' TextBox1.SelectedText = e.KeyChar
    ' Case "A", "B", "C", "D", "E", "F"
    ' TextBox1.SelectedText = UCase(e.KeyChar)
    ' Case Else
    ' 'MsgBox("tecla inválida(válidas são de 0 a F)")
    ' End Select
    ' End If
    ' e.Handled = True
    'End Sub

Trocando a tecla Enter pela tecla TAB

Muito útil quando estamos preenchendo formulários com muitos campos na tela.

    'trocando Enter por TAB
    'isto utiliza o evento KeyPreview de um form
    'é seletivo - funcionará para os textboxes, checkboxes de datetimepickers do form
    'Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    ' If e.KeyCode = Keys.Enter And Not (e.Alt Or e.Control) Then
    ' If Me.ActiveControl.GetType Is GetType(TextBox) Or
    ' Me.ActiveControl.GetType Is GetType(CheckBox) Or
    ' Me.ActiveControl.GetType Is GetType(DateTimePicker) Then
    ' If e.Shift Then
    ' Me.ProcessTabKey(False)
    ' Else
    ' Me.ProcessTabKey(True)
    ' End If
    ' End If
    ' End If
    'End Sub
    'Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' Me.KeyPreview = True
    'End Sub

End Module