SgtKabukinan
Messages postés106Date d'inscriptionlundi 20 septembre 2004StatutMembreDernière intervention23 janvier 2010 16 nov. 2005 à 16:59
n'oublie pas qu'à chaque touche frappé tu passe en parametre le control !
SgtKabukinan
Messages postés106Date d'inscriptionlundi 20 septembre 2004StatutMembreDernière intervention23 janvier 2010 16 nov. 2005 à 16:57
euh... oui bah je te donne plus simple ;)
Dans un module
---------------
Sub maskDecimal(k As Integer)
'----- définition des variables
Dim c As String * 1
Dim s As String
'---- chaine de filtrage
s = ".," & vbBack
'---- formatage de la touche tapée
c = LCase(Chr(k))
'---- si c un caractere autorise, il s'affiche
If (k >= 48 And k <= 57) Or InStr(s, c) Then Exit Sub
'---- sinon pas d'affichage
k = 0
End Sub
tu met ca dans l'evenement OnKeyPress du textBox
-------------------------------------------------
Sub txt_KeyPress(KeyAscci as Integer)
Call maskDecimal(KeyAscci)
End sub
FENETRES
Messages postés196Date d'inscriptionjeudi 15 juillet 2004StatutMembreDernière intervention14 avril 2009 27 oct. 2004 à 12:27
Après lecture de ton code et pour répondre à une demande du forum, j'ai été contraint d'ajouter un autre exemple.
16 nov. 2005 à 16:59
16 nov. 2005 à 16:57
Dans un module
---------------
Sub maskDecimal(k As Integer)
'----- définition des variables
Dim c As String * 1
Dim s As String
'---- chaine de filtrage
s = ".," & vbBack
'---- formatage de la touche tapée
c = LCase(Chr(k))
'---- si c un caractere autorise, il s'affiche
If (k >= 48 And k <= 57) Or InStr(s, c) Then Exit Sub
'---- sinon pas d'affichage
k = 0
End Sub
tu met ca dans l'evenement OnKeyPress du textBox
-------------------------------------------------
Sub txt_KeyPress(KeyAscci as Integer)
Call maskDecimal(KeyAscci)
End sub
27 oct. 2004 à 12:27