hi,
i am working with vs 2003, cf version 1.1, and testing the application in hp
& asus pocket pcs. Yes, I am not getting any error, when any of those keys
is pressed(only one keystroke). But I am talking about the combination of
keys. for example, when the user taps the CONTROL key, it will be in a
pushed down state and next we press the CAPITAL key, an error message is
displayed (combination of CONTROL & CAPITAL keys). The same error message is
displayed when CONTROL+TAB is pressed, and sometimes with CONTROL + SHIFT
also.
What I meant by 'avoid the keystrokes' is, when the user press a particular
key, the corresponding action will be neglected, i.e, if the user is pressing
CONTROL key, no action has to take place.
I will paste the code here:
Private Function IsAlphaNumeric(ByVal Text As String) As Boolean
'returns true if all characters in a string are alphabetical or
numeric
'returns false otherwise or for empty string
Dim sTemp As String
Dim iLen As Integer
Dim iCtr As Integer
Dim sChar As String
sTemp = Text
iLen = Len(sTemp)
If iLen > 0 Then
For iCtr = 1 To iLen
sChar = Mid(sTemp, iCtr, 1)
If Not sChar Like "[0-9A-Za-z]" Then Exit Function
Next
IsAlphaNumeric = True
End If
End Function
---------------------
and uses the function in the key_up event of a text box:
Private Sub txtSample_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtSample.KeyUp
'function call here:
If Not IsAlphaNumeric(txtSample.Text) Then
If e.KeyData = Keys.Back Then
ElseIf e.KeyData = Keys.CapsLock Then
ElseIf e.KeyData = Keys.ControlKey Then
ElseIf e.KeyData = Keys.ShiftKey Then
ElseIf e.KeyData = Keys.Tab Then
Else
MessageBox.Show("Please Enter AlphaNumeric Values", "Invalid
Data", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1)
txtSample.Text = ""
txtSample.Focus()
End If
End If
End Sub
------------------------------------------------
regards,
hari
:
I think you're going to have to tell us a little more: what version of the
..NET CF are you running this with, for example? Where? Device or emulator?
Surely you don't get an error when you just press and release the Control
key. Please be very specific and show the code for the alphanumeric text
box or tell us exactly what control you are using and how it is configured.
I also don't understand what you mean by avoid the keystrokes...
Paul T.
hi,
my alphanumeric only text box reports error, when the combination of TAB,
CAPS LOCK, SHIFT, CONTROL, ENTER keys( any COMBINATION of these keys) are
pressed.
could you please tell me how to avoid the keystrokes(combination of any)
and
thus avoid the message?
Regards,
Hari