vb.net 的 textbox 的一些事件及字符串处理

2024年11月13日 10:31
有1个网友回答
网友(1):

用下列代码可以屏蔽TextBox3中的"\"字符。你可以举一反三
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Dim s As Integer
Dim i As Integer
Dim t As String
s = TextBox3.TextLength

For i = 0 To s
TextBox3.SelectionStart = i
TextBox3.SelectionLength = 1
If TextBox3.SelectedText <> "\" Then
t = t & TextBox3.SelectedText
End If
Next
TextBox3.Text = t
End Sub