简体   繁体   English

VB TextBox条目处理 - 缺少TAB键

[英]VB TextBox entry handling - TAB key missing

Windows 10/VS 2015 Community/Visual Basic 2014 Windows 10 / VS 2015社区/ Visual Basic 2014

I have written the following to input text from 13 TextBoxes. 我编写了以下内容,以从13个文本框输入文本。 It inputs each character with its own event. 它为每个角色输入自己的事件。 Each character is checked for being a valid character (numerals, letters, symbols) plus Cr (to move to next TextBox) and BS (to permit typo corrections). 检查每个字符是否为有效字符(数字,字母,符号)加上Cr(移至下一个TextBox)和BS(允许拼写错误)。 This works: 这有效:


'===== Enter Frequency =====

Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

    ichar = e.KeyChar()

    ckinchar()                                         'ck for input characters, or CR or BS keys

    If eoline = 1 Then                                  'has <cr> been detected?
        freq = inline                                   'Yes
        bufcnt = 0                                      'Reset counter
        eoline = 0                                     'Rest EOL flag
        TextBox1.BackColor = Color.LightGreen
        TextBox2.BackColor = Color.LightPink
        TextBox2.Focus()
        Exit Sub
    Else
        TextBox1.Focus()                                'No  - repeat inputting
    End If

End Sub

Problem: I wish to also use the TAB key (to be implemented as the Cr key) However the TAB key code fails to appear. 问题:我还希望使用TAB键(作为Cr键实现)但是TAB键代码无法显示。 In run mode pressing the Tab key causes the cursor to move up the displayed TextBoxs following the tabIndex order. 在运行模式下,按Tab键会使光标按照tabIndex顺序向上移动显示的文本框。 I've tried using KeyDown/Enter/TextChanged events to no effect - mostly problems getting implemented. 我尝试使用KeyDown / Enter / TextChanged事件没有效果 - 主要是实现的问题。

Can anyone suggest any errors I might have in first two lines, or alternative choice. 任何人都可以建议我可能在前两行或其他选择中出现任何错误。 Is/are there any Properties in the TextBox I should be looking at. 我应该查看TextBox中是否有任何属性。

TIA Day Watson TIA Day Watson

Private Sub TextBox1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles TextBox1.PreviewKeyDown
    If e.KeyCode = Keys.Tab Then
        Me.Text = "TAB Captured" 
    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM