How To Make An Object Move Using Arrow Keys
How do i make an object move using then arrow keys (up, down, left, right). I figured out how to make things using command buttons but would like to use the arrow keys.
Any help would be appreciated
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Arrow Keys To Move Object
I currently have cmds to use this command:
imgPlayer.Top = imgPlayer.Top - 50
to move up, down, right and left and such - how do I change this so I use the arrow keys instead?
How Do I Make Arrow Keys Move Images?
How would I make an image move so when I push the "up arrow" it would move it 10 twips? I thought it would be
If vbKeyRight = True Then
Elseif vbkeyleft Then
Elseif vbKeyUp then
Else vbkeydown then
but its not can someone help me?
How Do U Make Keyboard Arrow Keys Move A Picture Box?
well i pretty much said it in the title.
i was wondering how would you make a picture box or an object repond
to the arrow keys.
for example i have a picture and i want to move right when i press the
right arrow on my keyboard. what is code for that?
if anyones knows the code please answer.
thank you very much.
How Do I Make An Image Move According To The User Arrow Keys On A Keyboard?
I'm desperatly trying to make a game in Visual Basic but have hit a problem. I have an image, an army tank. I want the tank to move when the user presses his/her left/right/up/down buttons on their keyboard adn the image moves according to the keyboard direction. HOw would I do this in vb 6?
need an urgent reply!!!!
Move Objects With Arrow Keys
How i can move the objects(by example a label or a textbox) with arrow keys in the form design??
I tried, but the objects is not moving inside the form design.
Simple question, but i don't know to do this.
Arrow Keys To Move A Simple Image
Im just trying to pick up the basics here, how would i go about moving an image around using the arrow keys, or any keys for that matter.
And on a seperate question, how do you make a background image scroll horizantally or across the X-axis?
Writing Code For Arrow Keys To Move Around Form Textboxes
i have an input form where users input machine tasks etc
there are about 5 textboxes and a combo and a few buttons.
and my manager has said he would like for them to be able to use arrow keys to go left right up down etc
so i was thinking like this
if key = arrow up then
if textbox.gotfocus then
elseif textbox2.gotfocus then
elseif key = arrow down then
etc etc etc
i hope you get the point
what i would like to know is....
Is this really bad practice? as in, is it practical? will it be very buggy?
How else could i accomplish this?
How would i write the code like above? i.e. how do i check if a textbox has got focus? and how to i check for the button pressed?
would i put it as
Sub Keypress ?
thanks for help!
How Would You Make 1 2D Object (A) Move To Another 2D Object (B) Thorough X, Y?
I know I new but please help!
Ive been looking all over for a programmer that could answer
this question but have had no luck so far. I want to make a game
where one 2D object (A) on the screen will move to another
2D object (B) on the screen at a moderate speed from wherever 2D object
(B) may be.
Also I was looking for someone that could answer the question
about animation while object (A) is moving to object (B).
Hey I was wondering how I could get input from one of the arrow keys to do an action.
Using Arrow Keys??
I'm a visual basic beginner only 15
How can i use arrow keys and/or other keys in Vb?? Is there an Inkey$ or something? Please help
The Arrow Keys?
Try as I might I can't seem tell when the arrow keys are pressed. Has anyone done this before? At this point Im looking for all the hep I can get.
Please Help, Arrow Keys
Okay, I know I must be doing something stupid.. but in the VB IDE environment at design time my arrow keys won't work. No matter what has focus when I use my arrow keys it scrolls through properties. The only way I can move the cursor around is with the mouse.. what am I doing wrong. It didnt used to do this, and my arrows still work fine in other programs.
how can i detect when an user press the Arrow Keys in a TextBox or the PAgeDown PageUp ones..
i've tried the KeyPress(Keyascii as Integer) event...
but it doesn't detect some keys like these I need...
appreciate any help.. thanx
i'm going to ask u a very sily question,"How to use the arrow and the 'F' keys?" Plz guide me in details.
When I use the press key event and the ascii codes for the arrow keys, nothing happens. At first I though it was a problem with the ascii codes I had got, so I made a tiny programme that told you the ascii of all the keys you pressed when you pressed them. It worked for most of them, but not for the arrow keys. I think this is because There is something already happening for the arrow keys. Please can you tell me how to make something happen When I press the arrow keys.
UP & Down Arrow Keys VB
Private Sub cboPartNumber_Validate(Cancel As Boolean)
so that when i press the TAB key my selection changes.
However when i use my up & down arrow my selection doesnt change.
What command do i need to use to allow the up & down arrow keys to act in the same way as my tab key using the vaildate event.
Using Arrow Keys
Im brand new to programming and trying to make a little image on the screen move, up until now ive just been using the keypad (8,6,4,2) to move the image, cuz i couldnt find the ascii numbers for the arrows. Now i have found out that there is no ascii numbers for the arrows lol. How do i use the arrow keys to move? I know i need to use keyDown??? Heres my code for using 8 6 4 2:
Private Sub Form_KeyPress(KeyAscii As Integer) If tmrCarMove.Enabled = True Then '******************************** 'Move Frogger to the Right '******************************** If KeyAscii = 54 And imgFrog.Left < 5280 Then imgFrog.Left = imgFrog.Left + 100 Call Check '******************************** 'Move Frogger to the Left '******************************** ElseIf KeyAscii = 52 And imgFrog.Left > 0 Then imgFrog.Left = imgFrog.Left - 100 Call Check '******************************** 'Move Frogger UP '******************************** ElseIf KeyAscii = 56 Then imgFrog.Top = imgFrog.Top - 400 Call Check '******************************** 'Move Frogger DOWN '******************************** ElseIf KeyAscii = 50 And imgFrog.Top < 5760 Then imgFrog.Top = imgFrog.Top + 400 Call Check End If End If End Sub
Is there a simple way to change this so i can use the arrows??? Thanks!!
Firstly Hi guys!
How do I make it so that VB 6 will recognise the arrow keys ? I mean I have no idea where to begin. All I want to do is make it so I can move a image with the arrow keys I am kinda a noob when it comes to visual basic as I have been doing it at college for 3 years but my teachers dont see the need to teach us the most basic things.... anyway any help on this would be most apprieciated...
4 Arrow Keys
i haf a problem....i am using the 4 arrow keys in the keyboard to invoke command buttons on the interface...the problem is when i click any of the arrow key, the corresponding button doesnt actually being invoked...bcuz the cursor moves on to the next nearest button and selects it....and as i keep on clicking the arrow key, the cursor keep on selecting diffrent type of command buttons...its like i am using the arrow keys to select a file i need, and then clicking enter to open the file....the command butons are invoked only if i associate shift,ctrl or alt key wif the arrow key, as in i click either of those key, hold it down and then when i press the arrow keys the command button excutes its function...now i dont want this....i want the command button to be invoked only by pressing the arrow keys and no other associating keys...note that besides te arrow keys, if i assign the functions to other key, lets say W,A,S,D...the command button is invoked beside having to press ctrl,sift,or alt key....but i want to use my arrow keys...so please help.....
Doing Something With Arrow Keys
I need the ascii values of the arrow keys on the keyboard. I want to use the keypress event with Form1. I have several charts but none show the value. Plz Help.
Does anyone know how to get arrow keys to respond when there is more than one control on the form, I set keypreview to true and have tried setting focus to the form but that doesn't wanna work.
Using Arrow Keys In VBA...?
I am using VBA and am trying to get the arrow keys on the keyboard to activate some code.
When I press the left arrow key, I want a label (which is already on my form) to display "Left". When the right key is pressed, "Right" and so on.
I am using the VBA in MS Word, but there is no KeyPreview option for the form.
Any information about how I can get the keys to work in VBA??
Ok... I thought I had the code to move a Command Button around the screen using the Arrow keys... but it doesn't appear to be working.
Can someone post some code for me?
Thanks in advance
Arrow Keys? (Done)
What is the ascii code for the arrow keys on the keyboard? ...
Maybe this can help:
Private Sub Form_KeyPress(KeyAscii As Integer)'Set CaseSelect Case KeyAsciiCase "119"'Reset Rest intfront = -1 intright = -1 intleft = -1'Start Motion intback = intback + 1 Image1.Top = Image1.Top - 90'Picture Image1.Picture = imgback(intback).Picture'Check Max Pic If intback = 8 Then intback = -1 End If'Rest goes on for left, right, and back
I can't get arrows to work If anyone has anything to help me out, i would really like it.
Arrow Keys, Almost?????????
i put in this code, and it is a picture1
If KeyCode = 39 Then
' right arrow key was pressed
Picture1.Move Picture1.Left - 100
If KeyCode = 37 Then
' left arrow key was pressed
Picture1.Move Picture1.Left + 100
If KeyCode = 38 Then
' up arrow key was pressed
Picture1.Move Picture1.Top + 100
If KeyCode = 40 Then
' down arrow key was pressed
Picture1.Move Picture1.Top - 100
but it doent move the picture wy? please help
what are the VB variables for the arrow keys (up,down,left,right) ?????
How do we move across different text boxes in a form using arrows keys- up, down, right and left?
Use Off Arrow-keys
I've got a problem while using the arrow keys to give steering commands to an object(Aircraft). The steering commands do work well, however each time an arrow key is pushed, the focus is also moving along the form and even more painfull, if the focus reaches an option field the selected option will be changed on the way.
Is it possible to "stop" this unwanted sideeffect?
Using Arrow Keys
Hi guys and gals!
I have come across a problem in designing an interface that simply has
The aplication requires keyboard use only (no mouse), so the current
program uses all windows standard accelerators and function keys. A
request has been made to navigate between fields using the arrow keys.
I already have keypreview set to true and am processing keystrokes
through the KeyDown event. However, the arrow keys don't fire any
events at all when pressed by themselves. (I have tried KeyPress as well
to no avail) Although, if I hold down a modifier key (shift, ctrl, alt)
then press the arrow key, the event fires and the code works perfectly.
So it seems to be a bug. I have searched Miscrosoft MSDN and Technet
but can find no information related to this issue.
I know I could hook my window and build my own handler, but I would
prefer to explore all other avenues before resorting to anything that
could potentially cause system instability.
Has anyone experienced this issue and found a solution?
Thank you, Chris
Need Help! Need To Know How To Use Arrow Keys
I already know how to use the letter keys in a form by using the KeyAscii and if..then statements. I made a form changes the event to Form_KeyPress and typed in
label1.caption = KeyAscii
That gave me the Number for most of the keys but it didnt give me one for the arrow keys. Could someone give me sample code on how to use the arrow keys to move an image in a form. Thanks Again ~Greg~
Using The Arrow Keys?
I am working on a simple program to help teach kids their times tables ( 2 x 8 = ). I am using a array of labels to display the math problem. I am trying to use a Shape to indicate which problem is the current one.
The problem I am having is how to use the Arrow keys to move to the next one, or back one problem. How do I use the Arrow keys? I have the logic to do the moving, I just can't get the Arrow keys. I have put my logic (even a Debug.Print ) in the Change event, KeyDown event, KeyPress event and nothing works. In the KeyDown event I get a response but not the right one. Here is what I got so-far:
Code:Private Sub txtAnswer_KeyDown(KeyCode As Integer, Shift As Integer)
If vbKeyRight Then
Debug.Print "Right Arrow"
this will do the Debug.Print no matter what key I press. Why?
Any Help would be Great
GOD said it, I believe it, so that settles that.....
Edited by - kf4iis on 8/11/2003 11:45:46 AM
Those Pesky Arrow Keys
I'm trying to trap the arrow keys. I have a command button on a frame on a form. I set form.keypreview to true, and try to trap the keydown event on both the form and the button (the frame doesn't have the KeyDown event) but the keypress doesn't show up in either trap. I cant trap lots of other keys, but not the arrows. What's up with that?
Oh, and passel, feel free to tell me how wrong I was when I said that trapping arrow keys was easy (http://www.xtremevbtalk.com/showthread.php?t=90646)
Trap Arrow Keys
Hi there, All
Is there a way to trap the arrow keys in an MS Access form. I want to be able to scroll through items I have listed in my combobox by pressing the up/left (for previous) and down/right (for next) keys.
I have the keypreview property set to True and placed the code to trap the arrow keys in the Form_KeyDown event. The function works (it does scroll to the next/previous item in the combobox list), but then it loses focus to the next or previous control in the tab order. I've tried to reset focus to the control (combo1.SetFocus) but to no avail.
Any help would be most appriciated.
Arrow Keys To Navigate DB
I have a data project that I want to use the arrow keys, left and right , to go forward and backward in my rs. I want the user to be able to either press my cmdNext or cmdBack , or use the arrow keys. Can someone point me in the right direction to do this?
Form_keydown With Arrow Keys
I'm having a problem triggering the form_keydown event when using the arrow keys. I have the KeyPreview set to true, and It works fine as long as the focus isn't on one of my buttons. However, when one of my buttons are focuses, pressing the arrow key moves to the next button, even though all buttons have TabStop set to false.
Any other way to detect this?
Combo Box And Arrow Keys
here's the question -
I want the user to be able to change the highlighted option in an option box, using the arrow keys on the keyboard. Can this be done? How?
I know that I have to use the arrow keys in the keydown event, but I am not sure how to get the option to change without clicking on the combo box and selecting a different one.
I would like the user to be able to keep pressing the arrow key, and the options in the combo box to cycle through, in order.
Any help appreciated
Intercepting Arrow Keys
I have a form with KeyPress set to true. It has for commandbuttons = Command1(0-3) on it. They are placed in two rows with two columns, i.e.:
I want to intercept the arrow keys to set the focus appropriately. For instance, with the focus on Command1(0), I press the down key and the focus should then be on Command1(2). This is the code I use, but it doesn't even seem to be initiated, since the arrow keys work in the default manner (down key moves from 0 to 1). Any suggestions?
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Static iC As Integer
Select Case KeyCode
Case vbKeyUp 'Up
iC = iC - 2
If iC < 0 Then iC = iC + 2
Case vbKeyDown 'Down
iC = iC + 2
If iC > 4 Then iC = iC - 2
Case vbKeyRight 'Right
iC = iC + 1
If iC > 4 Then iC = 0
Case vbKeyLeft 'Left
iC = iC - 1
If iC < 0 Then iC = 4
Use Arrow Keys To Navigate
I have a form with about 15 textboxes. At present I am using the TAB and mouse to navigate. The end uesrs are not satisfied. Thay want to use the arrow keys instead.
I have no idea how to tackle this problem. Any help will be appreciated.
Thanks in advance.
How To Use The Arrow Keys In A Form
How will I use the arrow keys or the page up or page down keys in a form to navigate thru the texboxes or any object in a form?
UserControl Tab And Arrow Keys.
I've used the following code in two custom usercontrols.
It traps the arrow keys and uses PostMessage to call the next control in the tab order.
It works perfectly in the first control I made.
But it isn't working properly in a new control.
Also, the tab key never seems to get to this sub, but it still works with the 1st control.
But with the new control I have to use the tab key twice before focus will shift to the next control.
The original control has the KeyPreview property set to false.
I had to set it to True on the new control, otherwise UserControl_KeyDown never receives the event.
Maybe I've missed a setting somewhere?
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)'This handles keystrokes made while the button has focus Static bBlockLoop As Boolean If bBlockLoop Then Exit Sub Select Case KeyCode Case vbKeySpace bBlockLoop = True m_eButtonState = Down SetButtonPic Case vbKeyReturn bBlockLoop = True m_eButtonState = Down SetButtonPic UserControl.Refresh Sleep 50 m_eButtonState = HasFocus RaiseEvent Click SetButtonPic Case vbKeyRight m_eButtonState = Normal SetButtonPic KeyCode = 0 ' simulate a tab key PostMessage UserControl.ContainerHwnd, WM_KEYDOWN, ByVal &H27, ByVal &H4D0001 Case vbKeyDown m_eButtonState = Normal SetButtonPic KeyCode = 0 PostMessage UserControl.ContainerHwnd, WM_KEYDOWN, ByVal &H28, ByVal &H500001 Case vbKeyLeft m_eButtonState = Normal SetButtonPic KeyCode = 0 ' simulate a shift+tab key PostMessage UserControl.ContainerHwnd, WM_KEYDOWN, ByVal &H25, ByVal &H4B0001 Case vbKeyUp m_eButtonState = Normal SetButtonPic KeyCode = 0 PostMessage UserControl.ContainerHwnd, WM_KEYDOWN, ByVal &H26, ByVal &H480001 End Select RaiseEvent KeyDown(KeyCode, Shift) bBlockLoop = FalseEnd Sub
Pressing The Arrow Keys
How do can I make things happen when I press the arrow keys on my form? Ive been thinking for a while now but I cant figure it out
This is what I thought was the obvious answer:
Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = vbKeyLeft Then MsgBox "yehaa!" End IfEnd Sub
Trapping Arrow Keys
My program should respond to the arrow keys, but I can't trap them individually. Only the KeyDown sub is being called, and they're all 255.
AHH HELP Keypress Arrow Keys
How do i track the pressing of the arrow keys?
They dont fire the keypress event.
Also what is there ascii #?
If they dont have an ascii # can I send an arrow key with sendkeys?
SendKeys & Arrow Keys?
Does anyone have problems sending arrow keys to other applications using SendKeys? Here's my code:
AppActivate "Caption of application here"