'Pour le point => virguleif Chr(KeyAscii) "." then KeyAscii Asc(",") if not((Keyascii >= 48 and KeyAscii <=57) or _ KeyAscii =8 Or KeyAscii = Asc(",")) then KeyAscii =0 'annule la touche fait par l'utilisateur end if
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionFunction isValidTextBox(sText As String, parametre_regional As String) As Boolean 'Check is the textbox has the correct format Dim FORMAT_TEXTBOX As RegExp Dim MATCHES, MATCH As Object Dim bReturn As Boolean Set FORMAT_TEXTBOX = New RegExp FORMAT_TEXTBOX.IgnoreCase = True If parametre_regional = "virgule" Then FORMAT_TEXTBOX.Pattern = "[0-9,]*" Else FORMAT_TEXTBOX.Pattern = "[0-9\.]*" End If Set MATCHES = FORMAT_TEXTBOX.Execute(sText) bReturn = False For Each MATCH In MATCHES If Len(MATCH.Value) = Len(sText) Then bReturn = True End If Next isValidTextBox = bReturn End Function Private Sub Text1_Change() If Not isValidTextBox(Text1.Text, "virgule") Then MsgBox "bouuuhhh , pas bien !!" Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) Text1.SelStart = Len(Text1.Text) End If End Sub