VB工程--百例56--用键盘控制小方块移动

前端之家收集整理的这篇文章主要介绍了VB工程--百例56--用键盘控制小方块移动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Option Explicit
Dim i As Integer
Private Sub form_keydown(keycode As Integer,shift As Integer)
If keycode = 37 Then 如果按下键值为37的键
Shape1.Left = Shape1.Left - 100 图形控件想左移动
ElseIf keycode = 38 Then
Shape1.Top = Shape1.Top - 100 同理
ElseIf keycode = 39 Then
Shape1.Left = Shape1.Left + 100
ElseIf keycode = 40 Then
Shape1.Top = Shape1.Top + 100
End If

End Sub

原文链接:https://www.f2er.com/vb/260391.html

猜你在找的VB相关文章