Hi,
thank you for your help. However, I need to get the value, not just
to check for it. I know how to check for the keys, what I need is the
value (e.g if D2 or NumPad2 then 2) so I can then select the 2nd
month.
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 (e.g. returns 'e' instead of 5)
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 suggestions?
thank you
_dino_
On Wed, 2 Mar 2005 21:29:02 -0800, Crouchie1998
<Cr**********@discussions.microsoft.com> wrote:
Here's your solution:
Start a new Windows application & add a combobox (ComboBox1) to your form
Now, paste in the code below:
Const WM_KEYDOWN As Integer = &H100
Protected Overrides Function ProcessCmdKey _
(ByRef msg As System.Windows.Forms.Message, _
ByVal keyData As System.Windows.Forms.Keys) As Boolean
If msg.Msg = WM_KEYDOWN Then
Return Not (keyData >= Keys.NumPad0 And keyData <= Keys.NumPad9) _
AndAlso Not (keyData >= Keys.D0 And keyData <= Keys.D9)
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
-----------------------
It only allows you to type in numbers abover the QWERTY... & from the
numeric pad.
I hope this helps