User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 361,561 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,029 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 365 | Replies: 2
Reply
Join Date: Jan 2008
Posts: 15
Reputation: mark192 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
mark192 mark192 is offline Offline
Newbie Poster

Making keystrokes move a picture box?

  #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

 picturebox1.location = picturebox1.location + 1 

when a key is pressed...

help please!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 15
Reputation: mark192 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
mark192 mark192 is offline Offline
Newbie Poster

Re: Making keystrokes move a picture box?

  #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  
Join Date: Nov 2007
Location: Jogja
Posts: 2,259
Reputation: Jx_Man is just really nice Jx_Man is just really nice Jx_Man is just really nice Jx_Man is just really nice Jx_Man is just really nice 
Rep Power: 9
Solved Threads: 191
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Nearly a Posting Maven

Re: Making keystrokes move a picture box?

  #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 1:36 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 2:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC