Textbox et séparateur de millier

Sinsitrus Messages postés 849 Date d'inscription samedi 11 juin 2005 Statut Membre Dernière intervention 21 août 2015 - 26 août 2014 à 14:20
Whismeril Messages postés 19027 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 24 avril 2024 - 26 août 2014 à 14:32
Bonjour à tous !

J'ai bidulé un bout de code pour avoir la fonction de séparateur de millier dans ma textebox que voici :

    Private Sub TextBox6_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
        If Not ",.1234567890".Contains(e.KeyChar) And e.KeyChar <> vbBack Then e.KeyChar = Nothing

        Dim Pos As Integer
        Pos = TextBox6.SelectionStart

        If e.KeyChar = "." Then
            e.Handled = True
            TextBox6.Text = TextBox6.Text.Insert(Pos, ",")
            TextBox6.SelectionStart = Pos + 1
        End If

    End Sub

    Private Sub TextBox6_LostFocus(sender As Object, e As System.EventArgs) Handles TextBox6.LostFocus
        TextBox6.Text = Format(TextBox6.Text, "Standard")
    End Sub


Qu'en pensez-vous et comment je peut améliorer ce code svp ?

Merci d'avance !

----------
J'ai débuté VB10 depuis le 25/08/2014
OS            : Windows 7 Pro 64 Bit
Plateforme    : Visual Studio 2010

1 réponse

Whismeril Messages postés 19027 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 24 avril 2024 656
26 août 2014 à 14:32
0
Rejoignez-nous