Private Sub TextBox1_KeyPress(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyPressEventArgs) _ Handles TextBox1.KeyPress If TextBox1.Text.LastIndexOf(",") <> -1 And _ e.KeyChar = "," Then e.KeyChar = Nothing End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim virgule As Byte = 0 For i As Integer = 0 To (Len(sender.text) + 1) ' Parcours le sender pour savoir If sender.text(i) = "," Then ' s'il y a déjà une virgule. virgule += 1 End If Next If virgule > 1 Then ' S'il y a déjà une virgule, et que le caractère If e.KeyChar = "," Then ' saisie est une virgule, alors ne pas l'afficher. e.Handled = True End If End If