Private Sub TBx_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim C As String * 1
On ClauseFrappe GoTo Nom, Phrase, Prénom, Virgule, Heure
Exit Sub
Nom: KeyAscii.Value = Asc(UCase$(Chr$(KeyAscii.Value)))
Exit Sub
Phrase: If TBx.SelStart = 0 Then KeyAscii.Value = Asc(UCase$(Chr$(KeyAscii.Value)))
Exit Sub
Prénom: If TBx.SelStart > 0 Then C = Mid$(TBx.Text, TBx.SelStart, 1)
If UCase$(C) <> LCase$(C) Then KeyAscii.Value = Asc(LCase$(Chr$(KeyAscii.Value))) _
Else KeyAscii.Value = Asc(UCase$(Chr$(KeyAscii.Value)))
Exit Sub
Virgule: If KeyAscii.Value = Asc(".") Then KeyAscii.Value = Asc(",")
Exit Sub
Heure: If InStr(TBx.Text, ":") > 0 Or TBx.SelStart < TBx.TextLength Or KeyAscii.Value = Asc(":") Then Exit Sub
If TBx.TextLength < 2 Then On Error Resume Next: If TBx.Text & Chr$(KeyAscii.Value) < 24 Then Exit Sub
Application.SendKeys Chr$(KeyAscii.Value): KeyAscii.Value = Asc(":")
End Sub