Keypress event handling

Discussion in 'Software' started by ceal21c, May 24, 2006.

  1. ceal21c

    ceal21c Private E-2

    Hey Guys,

    Could someone help me out with some sample code that would allow me to detect when the enter key is pressed in a textbox. I've read that I need to configure event handling for the textbox etc. but I'm not sure exactly what that means.
     
  2. Kodo

    Kodo SNATCHSQUATCH

    we first need to know what language you are using.
     
  3. ceal21c

    ceal21c Private E-2

    I'm using VB6. This code did the job for me:

    Private Sub txtGetAnswer_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    KeyAscii = 0 ' Prevent Carriage Return reaching textbox
    'Do something here
    End If
    End Sub
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds