标题:请grief进来一下
只看楼主
silvermoon
Rank: 1
等 级:新手上路
帖 子:188
专家分:0
注 册:2004-8-20
 问题点数:0 回复次数:2 
请grief进来一下

我想请教一个问题

就是捕捉键盘事件时

怎么获取输入的每一个键?

比如我知道回车是vbenter

那其他所有的键呢?

搜索更多相关主题的帖子: grief 键盘 vbenter 回车 获取 
2004-09-13 15:21
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
得分:0 

看msdn,里面全有

我写了一个函数,可以在KeyDown事件里调用,获得按键名

Public Function GetKeyName(KeyCode As Integer) As String Dim SpStr As String Dim ArrSp() As String Select Case KeyCode Case 0 GetKeyName = "无" Case 8 GetKeyName = "BACKSPACE" Case 9 GetKeyName = "TAB" Case 12 GetKeyName = "CLEAR" Case 13 GetKeyName = "ENTER" Case 16 To 20 SpStr = "Shift|Ctrl|Alt|Pause|Caps Lock" ArrSp = Split(SpStr, "|") GetKeyName = ArrSp(KeyCode - 16) Case 27 GetKeyName = "Esc" Case 32 To 47 SpStr = "空格|Page Up|Page Down|End|Home|左方向键|上方向键|右方向键|下方向键|SELECT|SNAPSHOT|EXECUTE|Print Screen|Insert|Delete|Help" ArrSp = Split(SpStr, "|") GetKeyName = ArrSp(KeyCode - 32) Case 48 To 57, 65 To 90 '0-9,A-Z GetKeyName = Chr(KeyCode) Case 92 GetKeyName = "Win" Case 93 GetKeyName = "Right Mouse Key" Case 96 To 105 'NumPad0-9 GetKeyName = "NumPad" & Chr(KeyCode - 48) Case 108 GetKeyName = "NumPad Enter" 'NumPad Enter Case 106 To 111 'NumPad *,+,Enter,-,.,/ GetKeyName = "NumPad" & Mid("*+ -./", KeyCode - 105, 1) Case 112 To 127 'F1-F16 GetKeyName = "F" & KeyCode - 111 Case 144 GetKeyName = "Num Lock" Case 145 GetKeyName = "Scroll Lock" Case 187 GetKeyName = "=" Case 189 GetKeyName = "-" Case 192 GetKeyName = "`" Case 220 GetKeyName = "\" Case Else GetKeyName = "KeyCode:" & KeyCode End Select End Function


天津网站建设 http://www./
2004-09-13 21:41
silvermoon
Rank: 1
等 级:新手上路
帖 子:188
专家分:0
注 册:2004-8-20
得分:0 

谢谢了啊,不过我的VB没装MSDN

盗版的

……

还有就是有几个函数不懂意思


我是一棵菠菜~~菜菜菜菜菜~~~
2004-09-13 23:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-5253-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.342576 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved