Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 1.07 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to change the location of a picture box in VB 2010 using the arrow or wasd keys?
  2. Public Class Map1
  3.  
  4.     Private Sub USER_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  5.         User.Top = User.Top - 1
  6.     End Sub
  7.  
  8.     Private Sub USER_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
  9.         User.Top = User.Bottom + 1
  10.         'User.Location.X = 200
  11.     End Sub
  12. End Class
  13.        
  14. User.location = new point(200, User.location.y)
  15.        
  16. Private Sub Map_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  17.     If e.KeyCode = Keys.Up Then
  18.         User.Location = New Point(User.Location.X, User.Location.Y - 5)
  19.     ElseIf e.KeyCode = Keys.Down Then
  20.         User.Location = New Point(User.Location.X, User.Location.Y + 5)
  21.     ElseIf e.KeyCode = Keys.Left Then
  22.         User.Location = New Point(User.Location.X - 5, User.Location.Y)
  23.     ElseIf e.KeyCode = Keys.Right Then
  24.         User.Location = New Point(User.Location.X + 5, User.Location.Y)
  25.     End If