|
![]()
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim ch As Char = e.KeyChar
If Not Regex.IsMatch(ch.ToString(), "^[\b\r0-9a-fA-F]$") Then
e.KeyChar = "" '放棄輸入的非法字符
MessageBox.Show("請正確輸入16進制數!!!", "系統提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
e.KeyChar = Char.ToUpper(ch) '強制轉換為大寫字母,放過退格和回車符
End If
End Sub |
|