text Box | In Chinese according to the views of users, we all need to limit the Chinese input, today, I tried to find a way to limit the Chinese input, the test has passed, we also try it, we have any comments continue to mention, if willing to add my qq:36745349
This is done on the basis of yesterday's changes, the test has met everyone's request, if anyone has a better way also please exchange
Here's the code:
' Sunnyxing2004-04-01 Last Modified
Public Class MyTextBox
Inherits System.Windows.Forms.TextBox
Private M_strvalidtext as String = "0123456789.+-" & Chr (13). Tostring
Private m_blneditable as Boolean = True
#Region "code generated by the Windows forms Designer"
Public Sub New ()
MyBase.New ()
' This call is required by the Windows Forms Designer.
InitializeComponent ()
' Add any initialization after the InitializeComponent () call
End Sub
' UserControl1 overrides dispose to clean up the list of components.
Protected Overloads Overrides Sub Dispose (ByVal disposing as Boolean)
If disposing Then
If not (components are nothing) Then
Components. Dispose ()
End If
End If
Mybase.dispose (disposing)
End Sub
' Required by the Windows Forms Designer
Private Components as System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Windows Forms Designer
' You can use the Windows Forms Designer to modify this procedure.
' Do not modify it using the Code Editor.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()
components = New System.ComponentModel.Container
End Sub
#End Region
Private Sub mytextbox_keypress (ByVal sender as Object, ByVal e as System.Windows.Forms.KeyPressEventArgs) Handles MyBase. KeyPress
Dim strlocalstring as String
If EditAble Then
strlocalstring = M_strvalidtext & Chr (8). Tostring
Else
strlocalstring = M_strvalidtext
End If
If UCase (strlocalstring). IndexOf (UCase (E.keychar)) < 0 Then
e.handled = True
Beep ()
Else
End If
End Sub
Public Property Validtext () as String
Get
Return M_strvalidtext
End Get
Set (ByVal Value as String)
M_strvalidtext = Value
End Set
End Property
Public Property EditAble () as Boolean
Get
Return m_blneditable
End Get
Set (ByVal Value as Boolean)
M_blneditable = Value
End Set
End Property
Public Sub Checktext (ByVal sender as Object, ByVal e as System.EventArgs) Handles mybase.textchanged
Dim Cha as Char
Try
Cha = CType (Me.Text.Substring (me.selectionstart-1, 1), Char)
If m_strvalidtext.indexof (CHA) < 0 Then
Me.Text = Me.Text.Remove (me.selectionstart-1, 1)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.