-
keychar
I use this :
Code:
e.KeyChar = ChrW(44)
to determine if e.keychar is "," but
IT IS "."
I know "." is 46. So why ?
I use :
Code:
Private Sub txtEdit_Keypress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtedit.KeyPress
Try
'MsgBox("kepress")
If IsNumeric(e.KeyChar.ToString()) Or e.KeyChar = ChrW(Keys.Back) Or e.KeyChar = ChrW(44) Then
e.Handled = False 'if numeric display
txtedit.Tag = txtedit.Text
'Kiểm tra xem có nhấn nút back hay không.Nếu có thì gán giá trị là bằng 0
If e.KeyChar = ChrW(Keys.Back) Then
If txtedit.Text.Length = 1 Then
txtedit.Text = 0
Exit Sub
End If
End If
Else
Trangthai("Chú ý : Bạn chỉ được nhập số cho số lượng hàng thêm !!!")
e.Handled = True 'if non numeric don't display
End If
Catch ex As Exception
Dialog.Kieudialog(Dialog.Kieuanh.canhbao, "Đã có lỗi trong việc chặn các kí tự !!! " & vbCrLf & ex.Message, "Cảnh báo lỗi", Dialog.Kieunut.OK)
End Try
End Sub