All I want to do is move a button i have on the form by pressing the left arrow key, and I can not find the right way to do this......please help as it is driving me insane!
Thnaks,
Matt
Printable View
All I want to do is move a button i have on the form by pressing the left arrow key, and I can not find the right way to do this......please help as it is driving me insane!
Thnaks,
Matt
Welcome to the forums. :wave:
What have you tried that isn't working and it driving you nuts?
Hey,
Can you confirm exactly what you are trying to do?
It would sound like what you want to do is the following:
1) Handle the keypress event of the form
2) If the key being pressed is the left arrow key decrease the Left Property of the Button
3) If the key being pressed is the right arrow key change increase the Left Property of the Button.
Gary
To be honest I am just learning vb.net(obviously). All I want to do is make a button move to the left when left arrow key is pressed, and to the right when right arrow key is pressed. In vb6 it was something like:
if keypress = vbleft then
button.left = button.left + 10
end if
That's all I really want to do and I just cant figure it out. I know it's a very noob question and I appreciate the help!
Thanks,
Matt
Hey,
What you have there would appear to be valid, you just need to get it into .Net.
Have a look at using the KeyPress Event for the form:
http://msdn.microsoft.com/en-us/libr....keypress.aspx
In this event you can check the KeyCode that is passed in and check against the KeyCode Enumeration for the button you are interested in.
Gary
Thank you very much! I have figured it out! Now on to more learning! Seriously thanks again!
Matt
Hey,
Not a problem at all, glad you got it sorted out!!
Gary