1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Dim p
Dim masque
Private Sub CommandButton1_Click()
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 8 Or KeyCode = 37 Then ' flèche gauche et backspace
KeyCode = 0
If p > 0 Then p = p - 1
If p = 2 Or p = 5 Then p = p - 1
End If
If KeyCode = 39 Then ' flèche droite
KeyCode = 0
p = p + 1
If p = 2 Or p = 5 Then p = p + 1
End If
If Mid(masque, p + 1, 1) = "." Then
If KeyCode = 46 Then ' touche suppression
Me.TextBox1 = Left(Me.TextBox1, p) & "." & Mid(Me.TextBox1, p + 2)
End If
If Not (KeyCode >= 48 And KeyCode <= 58 Or _
KeyCode >= 96 And KeyCode <= 106) Then KeyCode = 0 ' Chiffres & lettes
End If
TextBox1.SelStart = p
TextBox1.SelLength = 1
End Sub
Private Sub UserForm_Initialize()
Set f = Sheets("SAISIE")
masque = "../../.."
TextBox1 = masque
p = 0
TextBox1.SelStart = p
TextBox1.SelLength = 1
End Sub
Private Sub TextBox1_Change()
p = p + 1
If p = 2 Then p = 3
If p = 5 Then p = 6
TextBox1.SelStart = p
TextBox1.SelLength = 1
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(Me.TextBox1) Then
Cancel = True
End If
End Sub
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
p = Me.TextBox1.SelStart
End Sub
Private Sub B_ok_Click()
[A1] = CDate(Me.TextBox1)
End Sub |
Partager