Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keypress

Status
Not open for further replies.

awesomebeats

Technical User
Nov 29, 2001
25
US
hello, i was wondering how I can command something to happen if a key is pressed. is there some way to do it without creating a whole new private sub for it? im scared that it will either be too early in the code or too far down and will miss the animation i want to skip. any ideas?
 
What exactly are you trying to do that you are worried about putting it in its own sub? I believe it has to be called in its own sub. Here is a simple example I use to insert the current time when the user presses the ' key:

Private Sub txtTime_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTime.KeyPress
If e.KeyChar = "'" Then
e.Handled = True
txtTime.Text = FormatDateTime(TimeOfDay, DateFormat.ShortTime)
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top