Capture <ctrl> t from a textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LegalIT
    New Member
    • Feb 2008
    • 15

    Capture <ctrl> t from a textbox

    Hi,

    I am trying to capture the sequence <ctrl> t from a textbox to automatically fill in the current date. I can see how to capture an individual character but I am having trouble catching the sequence.

    I am using VB.net.

    Any suggestions would be greatly appreciated!

    Thanks
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by LegalIT
    Hi,

    I am trying to capture the sequence <ctrl> t from a textbox to automatically fill in the current date. I can see how to capture an individual character but I am having trouble catching the sequence.

    I am using VB.net.

    Any suggestions would be greatly appreciated!

    Thanks
    Something like this in the KeyDown event will do:

    [CODE=vb]If Shift = 2 And KeyCode = Asc("T") Then
    'code to fill the date, something like: textbox1.text=t extbox1.text & date
    End If[/CODE]

    HTH

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      If I'm not mistaken, that looks like VB6 code.

      Anyway, don't forget that the accepted way to test bit positions within the Shift parameter is with AND, not =. For example...

      [CODE=vb]If (Shift and VbCtrlMask) And KeyCode = Asc("T") Then ' Control T ...[/CODE]

      Comment

      • LegalIT
        New Member
        • Feb 2008
        • 15

        #4
        I figured it out from your suggestions. Thank you both!!!

        LegalIT

        Comment

        Working...