J
Jem
Hi
I'm REALLY new to DotNet and could use a little help/advice please.
I have the following code which i've basically hacked together from a
similar VB routine...
Private Sub txtExpReqdForPlate_KeyPress(ByVal eventSender As
System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs)
Handles txtExpReqdForPlate.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
' Make sure values are numeric and accept + and - and .
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
If KeyAscii <> 13 And KeyAscii <> 43 And KeyAscii <> 45 And_
KeyAscii <> 46 And KeyAscii <> 127 And KeyAscii <> 8 Then
KeyAscii = 0
End If
KeyAscii = 0
System.Windows.Forms.SendKeys.Send("{tab}")
End If
eventArgs.KeyChar = Chr(KeyAscii)
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
This is used to only allow numeric characters (and a few others inc. the
backspace key) in a textbox. Why doesn't it let me use the backspace key?
As I said i'm really new to this and confess I don't really understand what
i'm doing, although I am trying to learn (slowly). Can any answers please
be as simple as possible otherwise it'll probably go straight over my head -
sorry!
Thanks
Jem
I'm REALLY new to DotNet and could use a little help/advice please.
I have the following code which i've basically hacked together from a
similar VB routine...
Private Sub txtExpReqdForPlate_KeyPress(ByVal eventSender As
System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs)
Handles txtExpReqdForPlate.KeyPress
Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
' Make sure values are numeric and accept + and - and .
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
If KeyAscii <> 13 And KeyAscii <> 43 And KeyAscii <> 45 And_
KeyAscii <> 46 And KeyAscii <> 127 And KeyAscii <> 8 Then
KeyAscii = 0
End If
KeyAscii = 0
System.Windows.Forms.SendKeys.Send("{tab}")
End If
eventArgs.KeyChar = Chr(KeyAscii)
If KeyAscii = 0 Then
eventArgs.Handled = True
End If
End Sub
This is used to only allow numeric characters (and a few others inc. the
backspace key) in a textbox. Why doesn't it let me use the backspace key?
As I said i'm really new to this and confess I don't really understand what
i'm doing, although I am trying to learn (slowly). Can any answers please
be as simple as possible otherwise it'll probably go straight over my head -
sorry!
Thanks
Jem