VB 代码!!
答案:3 悬赏:20 手机版
解决时间 2021-04-14 19:58
- 提问者网友:聂風
- 2021-04-14 02:46
怎么做一个移动按钮 当按小键盘8,6,2,4时可以朝上、右、下、左运动
最佳答案
- 五星知识达人网友:山河有幸埋战骨
- 2021-04-14 03:23
Private Sub Command1_KeyPress(KeyAscii As Integer)
If KeyAscii = 50 Then
Command1.Top = Command1.Top + 50
ElseIf KeyAscii = 52 Then
Command1.Left = Command1.Left - 50
ElseIf KeyAscii = 54 Then
Command1.Left = Command1.Left + 50
ElseIf KeyAscii = 56 Then
Command1.Top = Command1.Top - 50
End If
End Sub
If KeyAscii = 50 Then
Command1.Top = Command1.Top + 50
ElseIf KeyAscii = 52 Then
Command1.Left = Command1.Left - 50
ElseIf KeyAscii = 54 Then
Command1.Left = Command1.Left + 50
ElseIf KeyAscii = 56 Then
Command1.Top = Command1.Top - 50
End If
End Sub
全部回答
- 1楼网友:一把行者刀
- 2021-04-14 05:43
首先把窗体的“KeyPreview”属性设置为“True” 然后把编写下面代码
Private Sub Form_KeyPress(KeyAscii As Integer) '当按 2 时向“上”
If KeyAscii = 50 Then Command1.Top = Command1.Top - 20
'当按 4 时向“下” ElseIf KeyAscii = 52 Then Command1.Top = Command1.Top + 20
'当按 6 时向“左” ElseIf KeyAscii = 54 Then Command1.Left = Command1.Left - 20
当按 8 时向“右” ElseIf KeyAscii = 56 Then Command1.Left = Command1.Left + 20 End If End Sub 不知道这个可不可以帮到楼主
- 2楼网友:夜余生
- 2021-04-14 04:25
是按一次跑一下,还是按一次就一直跑
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯