Trabalhando com Strings

30/12/2009

0

Bom dia pessoal   Como faço para verificar em uma string se a mesma possui: caracteres maiúsculos, minúsculo e especiais?   caracteres especiais - todos aqueles diferentes de letras e números   Obrigado!
Thiago Reis

Thiago Reis

Responder

Posts

30/12/2009

Gnlima

Você pode pegar o caracter ASC através do método keyPress   Private Sub  text_box_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles text_box_KeyPress Dim KeyAscii As Short = CShort(Asc(e.KeyChar)) If KeyAscii >= 65 And KeyAscii <= 90 Then  MsgBox("Maiusculo") ElseIf KeyAscii >= 97 And KeyAscii <= 122 Then MsgBox("Min£sculo") ElseIf KeyAscii >= 48 And KeyAscii <= 57 Then MsgBox("N£mero") Else MsgBox("Caracteres Especiais") End If     End sub   Logo após você terá que ver entre a tabela ASCII  
Responder

30/12/2009

Gnlima

Você pode pegar o caracter ASC através do método keyPress   Private Sub  text_box_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles text_box_KeyPress Dim KeyAscii As Short = CShort(Asc(e.KeyChar)) If KeyAscii >= 65 And KeyAscii <= 90 Then   MsgBox("Maiusculo") ElseIf KeyAscii >= 97 And KeyAscii <= 122 Then MsgBox("Min£sculo") ElseIf KeyAscii >= 48 And KeyAscii <= 57 Then MsgBox("N£mero") Else MsgBox("Caracteres Especiais") End If     End sub   Logo após você terá que ver entre a tabela ASCII  
Responder

30/12/2009

Gnlima

Você pode pegar o caracter ASC através do método keyPress   Private Sub  text_box_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles text_box_KeyPress Dim KeyAscii As Short = CShort(Asc(e.KeyChar)) If KeyAscii >= 65 And KeyAscii <= 90 Then     MsgBox("Maiusculo") ElseIf KeyAscii >= 97 And KeyAscii <= 122 Then MsgBox("Min£sculo") ElseIf KeyAscii >= 48 And KeyAscii <= 57 Then MsgBox("N£mero") Else MsgBox("Caracteres Especiais") End If     End sub   Logo após você terá que ver entre a tabela ASCII  
Responder

08/01/2010

Paulo Sena

Caso seja somente identificar qual o formato do caracter vc pode utilizar a classe Char do framwork que ela possui todos testes, segue um exemplo usando c# em um projeto Web:

string strTeste = "TeSt@nD0!◄";
            char[] charArray = strTeste.ToCharArray();
            StringBuilder resultado = new StringBuilder();

            foreach (char c in charArray)
            {
                if (Char.IsUpper(c))
                {
                    resultado.Append(c + " - IsUpper <br/>");
                }
                else if (Char.IsLower(c))
                {
                    resultado.Append(c + " - IsLower <br/>");
                }
                else if (Char.IsSymbol(c))
                {
                    resultado.Append(c + " - IsSymbol <br/>");
                }
                else if (Char.IsNumber(c))
                {
                    resultado.Append(c + " - IsNumber <br/>");
                }
                else if (Char.IsPunctuation(c))
                {
                    resultado.Append(c + " - IsPunctuation <br/>");
                }
            }

            Response.Write(resultado.ToString());
Responder

16/02/2010

Eleuterio Gonzalez

pode montar um select case e verificar via keypress
Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar