Re: Windows.forms.keys collection

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The key code for a lower case 's' is 115, but the Keys enumeration does not
make a distinction between lower and upper case. You have two options:
1) convert all alphabetic characters to upper case before converting to the
Keys enum. 's' would become 'S' which would give you code 83 as you expect.
2) keep track of which characters are upper and lower case, and set the
shift key in the Keys enumeration along with the alphabetic character; note
that with this route you still have to convert the letter to upper case:
Dim key As UInteger
If (Char.IsUpper(c)) Then
key = Convert.ToInt16(c) Or Keys.Shift
Else
key = Convert.ToInt16(Char.ToUpper(c))
End If
This all assumes that you're dealing strictly with alphabetic characters. I
didn't test to see how it would respond to symbols and numbers.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets


"Oguzhan Filizlibay" <someemail@xxxxxxxxxxxxxx> wrote in message
news:O7L$6nOlHHA.492@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I have the below code for sending each character in a string as a Keys.x
enumeration. I've found that when I convert the char, it does not match
the enumeration item index and thereby generates a very random output. Any
ideas on how I can convert chars to their right equivalent in the Keys
enumeration.

thanks,

as an example:

Dim strCaseID As String = "s"


For Each c As Char In strCaseID
Dim key As UInteger = Convert.ToInt16(c)
DoKeyBoard(0, key)
DoKeyBoard(NativeMethods.KEYEVENTF.KEYUP, key)

Next


in this example s is somehow translated into 115 and this translates to
Keys.F4, which actually should be an 83 to be indicated right..


.