Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I need help
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Darkmantis




PostPosted: Tue Dec 06, 2005 6:07 pm   Post subject: I need help

How make stuff move around using the arrow keys?
Sponsor
Sponsor
Sponsor
sponsor
pavol




PostPosted: Wed Dec 07, 2005 10:21 am   Post subject: (No subject)

lets say your 'stuff' is a shape called shpBox. in the form_keydown procedure. you could use some code like this:
code:
Select Case vbKeyCode
     Case vbKeyUp
          For i = 1 To 100
              For j = 1 To 1000000
                    shpBox.Top = shpBox.Top - 100
              Next j
          Next i

End Select

the for loop just simply moves the object but the part that makes shpBox move up using the arrow key is select case vbkeycode case vbkeyup. vbkeyup is used for the up arrow key, vbkeydown for the down arrow key and so on.
hope this helps
Darkmantis




PostPosted: Wed Dec 07, 2005 12:03 pm   Post subject: (No subject)

umm when I press any key the object goes up, how do I make it just move up with the up arrow key?
pavol




PostPosted: Thu Dec 08, 2005 10:13 am   Post subject: (No subject)

forgot to include that part
to make it go up you use the code shpBox.Top = shpBox.Top - 100(or whatever speed you choose), down would be shpBox.Top = shpBox.Top +100, left : shpBox.Left = shpBox.Left -100, and right : shpBox.Left = shpBox.Left +100
Darkmantis




PostPosted: Thu Dec 08, 2005 12:44 pm   Post subject: (No subject)

ok thx a lot
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: