Solved

Trapping the Tab key in VB2010

Posted on 2014-07-28
4
192 Views
Last Modified: 2014-07-28
Here is the code that successfully traps the Enter key but not the Tab key???  What am I missing?

   Private Sub txtBegindate_keypress(sender As System.Object, e As System.EventArgs) Handles txtBeginDate.KeyPress
        Dim tmp As System.Windows.Forms.KeyPressEventArgs = e
        Dim myDateF As Date


        If tmp.KeyChar = ChrW(Keys.Enter) Or tmp.KeyChar = ChrW(Keys.Tab) Then
            myDateF = Format(DateAdd(DateInterval.Day, 49, DateValue(txtBeginDate.Text)), "short date")
            txtThroughDate.Text = myDateF
            txtFeatureStart.Focus()

            'txtSourceNumber.Focus()
        Else
        End If

    End Sub
0
Comment
Question by:Jeff_Kingston
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 40224222
0
 

Author Comment

by:Jeff_Kingston
ID: 40224231
Sorry I don't read German.

If this is the case, how does one check for either Enter or Tab????
0
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 40224241
0
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 40224274
Use the PreviewKeyDown event,
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question