- 生肖
- 蛇
- 性别
- 男
- 积分
- 208
- 积分
- 216
- 精华
- 0
- 阅读权限
- 30
- 注册时间
- 2012-4-28
- 最后登录
- 2012-6-1
- 帖子
- 30
- 生肖
- 蛇
- 性别
- 男
|
本帖最后由 sky_yx 于 2015-12-30 14:22 编辑
- [i]'[/i][i]*****************************************************************
- '本函数用于识别多按键同时按下,最多支持同时按下128个按键
- '编写时间:2005年6月10日,编写人:田野(Field MAX)
- '
- '函数用法:KeyClick([KeyDown][KeyUp])
- 'KeyDown 按下的KeyPass(可选)
- 'KeyUp 抬起的KeyPass(可选)
- '
- '使用方法:分别在KeyDown和KeyUp事件内使用本函数即可获得案件码。
- ' 获取案件码时可不输入附加值。
- '
- '*****************************************************************
- Public AllKeyPass(127) As Integer
- Public Function KeyClick(Optional ByVal KeyDown As Integer = 0, Optional ByVal KeyUp As Integer = 0) As String
- Dim i As Long
- Dim NewKeyPass As String
- For i = 0 To 127
- If KeyDown <> 0 And AllKeyPass(i) = KeyDown Then Exit Function
- Next
- For i = 0 To 127
- If AllKeyPass(i) = 0 Then
- AllKeyPass(i) = KeyDown
- Exit For
- End If
- Next
- For i = 0 To 127
- If AllKeyPass(i) = KeyUp Then AllKeyPass(i) = 0
- If AllKeyPass(i) <> 0 Then
- NewKeyPass = NewKeyPass & AllKeyPass(i) & ","
- End If
- Next
- If Len(NewKeyPass) = 0 Then
- KeyClick = "0"
- Else
- KeyClick = Left(NewKeyPass, Len(NewKeyPass) - 1)
- End If
- End Function
- ----------------------------------------------------------------------
- '演示
- Private Sub Command1_Click()
- Debug.Print KeyClick
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- Debug.Print KeyClick(KeyCode)
- End Sub
- Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
- Debug.Print KeyClick(, KeyCode)
- End Sub
- Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- Debug.Print KeyClick(Button)
- End Sub
- Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
- Debug.Print KeyClick(, Button)
- End Sub[/i]
复制代码
|
|