This change will allow for the tab key to be processed correctly.
Protected Overrides Function ProcessDialogKey(ByVal keydata As System.Windows.Forms.Keys) As Boolean
If TextBox1.Focused Then
Select Case keydata
Case Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, _
Keys.D8, Keys.D9, Keys.Back, Keys.Decimal, Keys.OemPeriod, Keys.NumPad0, Keys.NumPad1, Keys.NumPad2, Keys.NumPad3, _
Keys.NumPad4, Keys.NumPad5, Keys.NumPad6, Keys.NumPad7, Keys.NumPad8, Keys.NumPad9, Keys.Delete, Keys.Tab
Return MyBase.ProcessDialogKey(keydata)
Case Else
Return True
End Select
Else
Return MyBase.ProcessDialogKey(keydata)
End If
End Function
Powerguy wrote:
Hi, I am trying to allow users to only be able to enter numeric numbers into a textbox. The problem is that I cannot move focus with the tab key even if I allow it as an allowable key stroke. I have successfully achieved this thanks to abit of code I found from within these forums (thanks who ever posted it!): Protected Overrides Function ProcessDialogKey(ByVal keydata As System.Windows.Forms.Keys) As Boolean If txtboxAB.Focused Then Select Case keydata Case Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, _ Keys.D8, Keys.D9, Keys.Back, Keys.Decimal, Keys.OemPeriod, Keys.NumPad0, Keys.NumPad1, Keys.NumPad2, Keys.NumPad3, _ Keys.NumPad4, Keys.NumPad5, Keys.NumPad6, Keys.NumPad7, Keys.NumPad8, Keys.NumPad9, Keys.Delete, KEYS.TAB 'accept digits only Return False Case Else Return True End Select Else Return MyBase.ProcessDialogKey(keydata) End If End Function The problem I have is that the Keys.TAB does not seem to work. When it goes into the function it detects that a TAB key has been pressed (the same as the rest of the number keys) however it does not move the focus to the next textbox. Does anyone know how I can make this work?? PowaGuy