According to the views mentioned by netizens, everyone needs to limit Chinese input. Today, I tried it, I found a way to limit Chinese input, I have passed, everyone will try it, what comments continue, if you are willing to add me QQ: 36745349
This is the change made on the basis of yesterday, and the test has met everyone's request. If anyone has a better way, please exchange
Below is the code:
'Sunnyxing2004-04-01 Last Review Public Class MyTextBox Inherits System.Windows.Forms.TextBox Private m_strValidText As String = "0123456789 -." & Chr (13) .ToString Private m_blnEditable As Boolean = True
#Region "Windows Form Designer Generated Code"
Public Sub New () MyBase.new () 'This call is required for the Windows Form Designer. InitializeComponent ()
'Add any initialization after INITIALIZECOMPONENT ()
End Sub
'UserControl1 Rewinds Dispose to clean the component list. Protected overloads overrides sub dispose (byval disposing as boolean) ing disponation kiln (Components Is Nothing) Then components.dispose () end if endiffs) End Sub
'Windows Form Designer Supply Private Components as System.comPonentModel.icontainer
'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.
#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 () ElseEnd 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)
End if catch ex asktion
END TRY
End Sub
END CLASS