تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
A KeyCode to Strings Converter
#1
كود :
            '**************************************
' Name: A KeyCode to Strings Converter
' Description:It is a function that converts keycodes like those used in _KeyDown events, to strings like "Ctrl", "Alt", "F", "/", which are recognizable to the end-user. Great for game programmers.
' By: Alexander Chia (from psc cd)
'
' Inputs:KeyCode as Integer
'
' Returns:KeyStr as String
'
' Assumes:If the user presses Shift+3, the function will not return "#", but will return "3" instead. It also uses easily recognizable symbols to represent certain keys, e.g "~" instead of "`", "\" instead of "|", and "Pg Dn", "Enter", "Space", to represent other keys.
'
' Side Effects:If a key inputted does not match with any of the strings listed, the string returned will be "!".
'**************************************

Public Function KeyStr(KeyCode As Integer) As String
'Copyright Alexander Chia Yan Sheng
Select Case KeyCode
Case 65 To 90
KeyStr = Chr(KeyCode)
Case 48 To 57
KeyStr = Chr(KeyCode)
Case 13
KeyStr = "Enter"
Case 9
KeyStr = "Tab"
Case 112 To 123
KeyStr = "F" & LTrim(Str(KeyCode - 111))
Case 27
KeyStr = "Esc"
Case 192
KeyStr = "~"
Case 187
KeyStr = "="
Case 189
KeyStr = "-"
Case 219
KeyStr = "["
Case 220
KeyStr = "\"
Case 221
KeyStr = "]"
Case 186
KeyStr = ";"
Case 222
KeyStr = "'"
Case 188
KeyStr = ","
Case 190
KeyStr = "."
Case 191
KeyStr = "/"
Case 16
KeyStr = "Shift"
Case 20
KeyStr = "Caps Lock"
Case 144
KeyStr = "Num Lock"
Case 145
KeyStr = "Scr Lock"
Case 17
KeyStr = "Ctrl"
Case 18
KeyStr = "Alt"
Case 32
KeyStr = "Space"
Case 45
KeyStr = "Ins"
Case 46
KeyStr = "Del"
Case 33
KeyStr = "Pg Up"
Case 34
KeyStr = "Pg Dn"
Case 8
KeyStr = "Back"
Case 36
KeyStr = "Home"
Case 35
KeyStr = "End"
Case 37
KeyStr = "Left Arrow"
Case 38
KeyStr = "Up Arrow"
Case 39
KeyStr = "Right Arrow"
Case 40
KeyStr = "Down Arrow"
Case 106
KeyStr = "* [Num Pad]"
Case 107
KeyStr = "+ [Num Pad]"
Case 111
KeyStr = "/ [Num Pad]"
Case 109
KeyStr = "- [Num Pad]"
Case Else
KeyStr = "!"
End Select
End Function
الرد
تم الشكر بواسطة: Ahmed_Mansoor , Amir_Alzubidy , awidan76 , awidan76
#2
السلام عليكم ورحمة الله وبركاته

أهلا بك أخي الكريم , كود جميل ومفيد , بارك الله فيك وجزاك الله كل خير .
كود :
For Each Breathe in MyLife
Breathe.Say " سبحان الله والحمد لله ولا إله إلا الله والله أكبر أستغر الله العظيم وأتوب إليه"
Next
الرد
تم الشكر بواسطة: viv , Amir_Alzubidy , awidan76


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم