hypz Posted June 28, 2012 Report Share Posted June 28, 2012 Alguém percebe de event KeyPress que me possa dar uma ajuda nas validações ? Como faço para ele me deixar introduzir um "-" (Hifen) ? Link to comment Share on other sites More sharing options...
NunoDinis Posted June 28, 2012 Report Share Posted June 28, 2012 posso-te ajudar.. queres que deixe introduzir um hífen ou não deixe ? Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org Link to comment Share on other sites More sharing options...
hypz Posted June 28, 2012 Author Report Share Posted June 28, 2012 Que deixe, aqui está o código que estou a usar. If Not IsNumeric(e.KeyChar) Then ToolTip1.Show("Campo Obrigatório, só números.", sender, 5000) e.KeyChar = Nothing End If Eu estava a testar com isto até mas nada dá resultado.. Dim allowedChars As String = "-" If Not IsNumeric(e.KeyChar) Then ToolTip1.Show("Campo Obrigatório, só números.", sender, 5000) e.KeyChar = Nothing ElseIf allowedChars.IndexOf(e.KeyChar) = 0 Then e.Handled = True End If Link to comment Share on other sites More sharing options...
NunoDinis Posted June 28, 2012 Report Share Posted June 28, 2012 a caixa de texto vai deixar digitar: - só números? - só letras ? - números e só o hifen? Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org Link to comment Share on other sites More sharing options...
hypz Posted June 28, 2012 Author Report Share Posted June 28, 2012 (edited) Números e hifen. É para um código de postal Tanto pesquisei que encontrei a forma do keypress mas para letras só xD Edited June 28, 2012 by hypz Link to comment Share on other sites More sharing options...
hypz Posted June 28, 2012 Author Report Share Posted June 28, 2012 Já descobri, assim funciona ! Dim lala As String = "-" If Not IsNumeric(e.KeyChar) And e.KeyChar <> lala Then ToolTip1.Show("Campo Obrigatório, só números.", sender, 5000) e.KeyChar = Nothing End If Obrigado na mesma pela ajuda, tópico resolvido ! 1 Report Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now