Usuário com melhor resposta
Bloquear Caracteres Específicos

Pergunta
-
Respostas
-
Então fica fácil. Adicione o código abaixo no evento TextChanged do seu TextBox:
Dim Text As String = TextBox1.Text If String.IsNullOrEmpty(Text) = False Then Text = Text.Replace("<","") Text = Text.Replace(">","") Text = Text.Replace("?","") Text = Text.Replace("\","") Text = Text.Replace("/","") Text = Text.Replace("|","") Text = Text.Replace("*","") Text = Text.Replace(Char.ConvertFromUtf32(34).ToString(),"") Text = Text.Replace(":","") TextBox1.Text = Text End If
Herbert Lausmann
- Marcado como Resposta Eduardo Milani quarta-feira, 8 de janeiro de 2014 18:07
Todas as Respostas
-
Boa tarde,
Coloque o código abaixo no evento KeyPress do seu TextBox:
If e.KeyChar = "<"c Then e.Handled = True If e.KeyChar = ">"c Then e.Handled = True If e.KeyChar = "?"c Then e.Handled = True If e.KeyChar = "\"c Then e.Handled = True If e.KeyChar = "/"c Then e.Handled = True If e.KeyChar = "|"c Then e.Handled = True If e.KeyChar = "*"c Then e.Handled = True If e.KeyChar = Char.ConvertFromUtf32(34) Then e.Handled = True If e.KeyChar = ":"c Then e.Handled = True
Herbert Lausmann
- Editado Herbert Lausmann quarta-feira, 8 de janeiro de 2014 17:30
-
Boa tarde,
Coloque o código abaixo no evento KeyPress do seu TextBox:
If e.KeyChar = "<"c Then e.Handled = True If e.KeyChar = ">"c Then e.Handled = True If e.KeyChar = "?"c Then e.Handled = True If e.KeyChar = "\"c Then e.Handled = True If e.KeyChar = "/"c Then e.Handled = True If e.KeyChar = "|"c Then e.Handled = True If e.KeyChar = "*"c Then e.Handled = True If e.KeyChar = Char.ConvertFromUtf32(34) Then e.Handled = True If e.KeyChar = ":"c Then e.Handled = True
Herbert Lausmann
Boa tarde,
Eu não posso utilizar o evento KeyPress pois o texto é inserido automaticamente e não digitado, teria que ser uma função ou por outro meio.
-
-
-
Então fica fácil. Adicione o código abaixo no evento TextChanged do seu TextBox:
Dim Text As String = TextBox1.Text If String.IsNullOrEmpty(Text) = False Then Text = Text.Replace("<","") Text = Text.Replace(">","") Text = Text.Replace("?","") Text = Text.Replace("\","") Text = Text.Replace("/","") Text = Text.Replace("|","") Text = Text.Replace("*","") Text = Text.Replace(Char.ConvertFromUtf32(34).ToString(),"") Text = Text.Replace(":","") TextBox1.Text = Text End If
Herbert Lausmann
- Marcado como Resposta Eduardo Milani quarta-feira, 8 de janeiro de 2014 18:07
-
Então fica fácil. Adicione o código abaixo no evento TextChanged do seu TextBox:
Dim Text As String = TextBox1.Text If String.IsNullOrEmpty(Text) = False Then Text = Text.Replace("<","") Text = Text.Replace(">","") Text = Text.Replace("?","") Text = Text.Replace("\","") Text = Text.Replace("/","") Text = Text.Replace("|","") Text = Text.Replace("*","") Text = Text.Replace(Char.ConvertFromUtf32(34).ToString(),"") Text = Text.Replace(":","") TextBox1.Text = Text End If
Herbert Lausmann