It sounds like you're using the "ChangedText" event in your program,
which fires after every character is entered.
Assuming that your wedge is a keyboard wedge, you should be able to
check the ProcessCmdKey on the form. You could try a line like
If keyData = Keys.Enter Then SendKeys.Send("{Tab}") : Return True
Now, that being said, I would create a user control based on the text
box that handles the Enter Key as a tab. It's really easy and with just
a few lines of code. The down side is that you have another dll that
you must distribute with your application.
I also like an event that fires if the value of the textbox changes,
instead of firing on every character. I'll throw this code in as well.
I've also included the optional bitmap entry, if you want to use your
own icon instead of the default icon for your control in the IDE,
otherwise; just delete the line with "ToolboxBitmap"
1) Create a user control called anything you want
2) Switch to the code screen in the IDE
3) Change all of the code above the system generated to
Imports System.ComponentModel
Imports System.Text
<ToolboxBitmap(GetType(YourBitMapName))> _
Public Class YourTextBoxName
Inherits TextBox
Private m_EnterValue As String
Public Event ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
.. . .
4) Add code under the system generated code
Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Enter Then SendKeys.Send("{Tab}"): Return True
End Sub
' Bonus code to see if the value changed
Private Sub YourControlName_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Enter
m_EnterValue = Me.Text
Exit Sub
Private Sub YourControlName_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Leave
If m_EnterValue <> Me.Text Then RaiseEvent ValueChanged(sender, e)
Exit Sub
5) Compile the program
6) Add a control under the IDE, Browse to the "bin" directory
containing the dll.
7) Add your new control to your form like any other form.
I've not tested this code, so I may have left something out. I just
pulled a subset of one of my user controls for this reply. Hope it
helps.
More information on creating user controls may be found in the book:
Mastering Visual Basic .NET by Evangelos Petroutsos. The book is pretty
informative, but my binding fell apart after six months!
