Solved

Trapping the Tab key in VB2010

Posted on 2014-07-28
4
188 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 49

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now