Making keystrokes move a picture box?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 18
Reputation: mark192 is an unknown quantity at this point 
Solved Threads: 0
mark192 mark192 is offline Offline
Newbie Poster

Making keystrokes move a picture box?

 
0
  #1
May 9th, 2008
I'm sure there is a simple way to make a keystrok such as the up arrow adjust the location of the picture box, however I don't know how to tell the program to perhaps

  1. picturebox1.location = picturebox1.location + 1

when a key is pressed...

help please!
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 18
Reputation: mark192 is an unknown quantity at this point 
Solved Threads: 0
mark192 mark192 is offline Offline
Newbie Poster

Re: Making keystrokes move a picture box?

 
0
  #2
May 9th, 2008
Actually scratch that, I really just want to know how I would say....

make a text box say "Left Key Pressed!" when i push the left key?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Making keystrokes move a picture box?

 
0
  #3
May 10th, 2008
handle it with keyDown Event.
this following code is form keydown event, you can do same with other controls.
  1. Private Sub Search_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  2. If e.KeyCode = Keys.Up Then
  3. 'PictureBox1.Top -= 10
  4. MsgBox("Key Up Pressed")
  5. ElseIf e.KeyCode = Keys.Down Then
  6. 'PictureBox1.Top += 10
  7. MsgBox("Key Top Pressed")
  8. ElseIf e.KeyCode = Keys.Left Then
  9. 'PictureBox1.Left -= 10
  10. MsgBox("Key Left Pressed")
  11. ElseIf e.KeyCode = Keys.Right Then
  12. 'PictureBox1.Left += 10
  13. MsgBox("Key Right Pressed")
  14. End If
  15. End Sub
Last edited by Jx_Man; May 10th, 2008 at 2:36 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC