Hi,
Can somebody help me with this problem please.
I need to get the value, not just to check for it, of a number
pressed but it has to work for both, numbers above QUERTY and numbers
entered from numeric pad.
I know how to check for the keys (which I am doing in the code below).
What I need is the value (e.g if D2 or NumPad2 then ' 2') so I can
then select the number 2 in my combo box (represents months).
I have several combo boxes on the form, some of which are dealing with
Strings (e.g. names of countries) which I am processing just fine, and
the others dealing with numbers (e.g. months). I process these fine
as well but only for numbers above QUERTY. What I need is the way to
do it for numeric keypad, too.
Here is the code I am using so far:
Private Sub WcboMonth_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles WcboMonth.KeyUp
If ((e.KeyCode >= Keys.D1) And (e.KeyCode <= Keys.D9)) Then
// ^^^^^ THIS WORKS FINE ^^^^^^^
Dim strString As String = ChrW(e.KeyData)
Dim index As Integer = 0
Dim i As Integer = 0
For i = 0 To WcboMonth.Items.Count - 1
If (WcboMonth.Items(i).Text.Chars(0) = strString) Then
index = i
Exit For
End If
Next
WcboMonth.SelectedIndex = index
End If
If ((e.KeyCode >= Keys.NumPad1) And _
(e.KeyCode <= Keys.NumPad9)) Then
// ^^^^^THIS DOES NOT WORK ^^^^^^
// (it returns 'e' if NumPad5 clicked
Dim strString As String = ChrW(e.KeyData)
Dim index As Integer = 0
Dim i As Integer = 0
For i = 0 To WcboMonth.Items.Count - 1
If (WcboMonth.Items(i).Text.Chars(0) = _
strString) Then
index = i
Exit For
End If
Next
WcboMonth.SelectedIndex = index
End If
End Sub
Any help will be appreciated
thank you
_dino_