VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Vi

by ReVegA (5 Submissions)
Category: Games
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Wed 5th June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Visual Basic. Two nice and easy, fully

Rate Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Vi



'** Use the numeric keypad to move objects
'** Compatible with all Winblows versions of 
'** Visual Basic.
'**
'** Usage: Good for a small game enginee,
'**        but not too suitable due to flickering
'**        sprites.
'**
'** From:  revega  May 06, 2002
'------------------------------------------     
' Create one timer, one shape, one text box.
' set MaxLength on text1 to 1.
'
' Put this inside [double click] the text1:

Call Timer1_Timer: text1.Text = ""


' Put this inside Timer1:

timer1.Interval = 80

If text1.Text = "6" Then         'Right
shape1.Left = shape1.Left + 40

ElseIf text1.Text = "4" Then     'Left
shape1.Left = shape1.Left - 40

ElseIf text1.Text = "2" Then     'Down
shape1.Top = shape1.Top + 40
   
ElseIf text1.Text = "8" Then     'Up
shape1.Top = shape1.Top - 40

' 40 is the amount to make the shape move.
' You can also replace shape with just about any other object,
' and make it bounce around.
    
End If

' This is how you would make it so you press a key and the object
' doesnt stop moving. I have only tested this with VB 3,
' but it should work with every Winblows version.
' This sub I took from vbcode.com because it was only for VB 4+
' and I needed it for VB 3, so I modified it so it would work.
'
' use this inplace of the text1 code above if you want
' the object to keep moving after you press a key.

Private Sub text1_KeyDown (Keycode As Integer, Shift As Integer)
    
Call Timer1_Timer
text1.Text = ""

End Sub

'NOTE:
'      If you are using this to make a GAME then you
'      will want to do this:
'      [also if you plan on hiding the textbox]
'
'   After you hide it, set its TABSTOP to 0
'   now disable tabstop on everything else on the form.
'
'   you can enable them with code later if needed.
'   the reason for this is when you compile you program
'   the first thing that becomes active (focused) is
'   the text box.
'   so if something else is focused by mistake....
'   you get the idea.

Download this snippet    Add to My Saved Code

Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Vi Comments

No comments have been posted about Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Vi. Why not be the first to post a comment about Use the numeric keypad to move objects around the form. Compatible with all Winblows versions of Vi.

Post your comment

Subject:
Message:
0/1000 characters