textbox1.CharacterCasing = CharacterCasing.Upper
Private Sub TextBoxClé_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBoxClé.KeyPress '######## Optimisation du code, au lieu de mettre si caractère controle ... on bloque, on met si le caractère n'est pas une lettre, on bloque ##### If Char.IsLetter(e.KeyChar) = False Then e.Handled = True End If End Sub Private Sub TextBoxClé_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBoxClé.KeyUp '############ RECUPERER LA VALEUR CLAVIER DU CARACTERE TAPPE ########## 'Dim Valeur As Integer = e.KeyValue 'MsgBox(Valeur) '####################################################################### If e.KeyValue = 50 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 220 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 192 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 221 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 55 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 57 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 48 Then TextBoxClé.Clear() MsgBox("Merci de ne pas mettre d'accents dans votre prénom ou nom !", MsgBoxStyle.Exclamation) End If If e.KeyValue = 8 Then TextBoxClé.Clear() End If End Sub Private Sub TextBoxClé_TextChanged(sender As Object, e As EventArgs) Handles TextBoxClé.TextChanged '######### Toutes les lettres tappées seront transformées en majuscule ######### TextBoxClé.CharacterCasing = CharacterCasing.Upper End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionlors de l'écriture de ma textbox.
Private Sub TextBoxClé_TextChanged(sender As Object, e As EventArgs) Handles TextBoxClé.TextChanged TextBoxClé.Text = TextBoxClé.Text.ToUpper End Sub
Regarde la propriété RightToLeft de ton Textbox. Elle doit être à No
@cmarcotte
J'ai regardé la propriété, je l'ai mise à "Yes" mais c'est encore plus déstabilisant
Private Sub TextBoxClé_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBoxClé.KeyPress If Char.IsDigit(e.KeyChar) = True Then e.Handled = True End If If Char.IsControl(e.KeyChar) = True Then e.Handled = True End If If Char.IsHighSurrogate(e.KeyChar) = True Then e.Handled = True End If If Char.IsPunctuation(e.KeyChar) = True Then e.Handled = True End If If Char.IsSeparator(e.KeyChar) = True Then e.Handled = True End If If Char.IsSymbol(e.KeyChar) = True Then e.Handled = True End If If Char.IsWhiteSpace(e.KeyChar) = True Then e.Handled = True End If End Sub
select case e.keyvalue case 50,220,92,48 'etc.. MessageBox.Show("blabla") (MsgBox obsolète) e.suppresskeypress = true case Else 'code pour le reste des touches end select