怎样写这样一个过程!!?!一个简单,但我不会的问题!

lubaixu 2004-05-01 11:33:19
问题是这样的:

怎么样实现按方向键后就触发一个过程。
比如我有一个过程add
我想按下"上、下、左、右"中的其中一键来调用add
...全文
36 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinaren502 2004-05-02
  • 打赏
  • 举报
回复
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if keycode=vbkeyup then
call add
end if
End Sub
online 2004-05-02
  • 打赏
  • 举报
回复
窗口的KeyPreview =True
Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim txt As String
txt = txt + Chr(KeyCode)
Text1.Text = "你按下的是 " + txt
'你可以看到方向健的keycode值,然后判断调用add
End Sub

Private Sub add()
MsgBox "ok"
End Sub

luoxiaoxiang 2004-05-02
  • 打赏
  • 举报
回复
窗口的KeyPreview 设置为 True
Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim a As Integer
a = KeyCode
If a > 36 And a < 41 Then
add
End If
End Sub

Private Sub add()
Print "asdfffgg"
End Sub

goodname008 2004-05-01
  • 打赏
  • 举报
回复
' 是这个意思?

Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print KeyCode
add
End Sub

Private Sub Form_Load()
Me.KeyPreview = True
End Sub

Private Sub add()
Debug.Print "add过程被调用"
End Sub

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧