Welcome!
This is from an RPG that a made last year in VB back when I started learning how to program. Hopefully this helps. It was just ripped out of my game.
->
Private Sub Form_KeyDown(KeyCode As Integer, shift As Integer)
Randomize
'lblTips.ZOrder 1000
If intCharacterCurrentXp <> 0 Then
'''''''''''''''''''''' up key ''''''''''''''''''''
If KeyCode = vbKeyUp Then
Character.Top = Character.Top - 900
If blnFight = True Then
Call FightRandomization
End If
End If
'''''''''''''''''''''''' down key '''''''''''''''''''''
If KeyCode = vbKeyDown Then
Character.Top = Character.Top + 900
If blnFight = True Then
Call FightRandomization
End If
End If
''''''''''''''''''''''' left key '''''''''''''''''''
If KeyCode = vbKeyLeft Then
Character.Picture = LoadPicture(App.Path & "\character1.gif")
Character.Left = Character.Left - 840
If blnFight = True Then
Call FightRandomization
End If
End If
'''''''''''''''''''''''right key ''''''''''''
If KeyCode = vbKeyRight Then
Character.Picture = LoadPicture(App.Path & "\character2.gif")
Character.Left = Character.Left + 840
If blnFight = True Then
Call FightRandomization
End If
End If
'**************************************** Collision detection *********************
If Character.Left < 0 Then
Character.Left = 0
ElseIf Character.Left > Me.ScaleWidth - 800 Then
Character.Left = Me.ScaleWidth - 800
End If
If Character.Top < 0 Then
Character.Top = 0
ElseIf Character.Top > Me.ScaleHeight - 1000 Then
Character.Top = Me.ScaleHeight - 1000
End If
'Print intFight
End If
'************************************** end of collision detection ******************8
End Sub