Private Sub TextBox1_Change()
Dim t$, n%, i%
t = TextBox1
For i = Len(t) To 1 Step -1
n = Asc(Mid(t, i, 1))
If n < 48 Or n > 57 Then t = Application.Replace(t, i, 1, "")
Next
TextBox1 = t
Moyenne
End Sub
Private Sub TextBox2_Change()
Dim t$, n%, i%, s, flag As Boolean
t = TextBox2
For i = Len(t) To 1 Step -1
n = Asc(Mid(t, i, 1))
If n < 48 Or n > 58 Then t = Application.Replace(t, i, 1, "")
Next
s = Split(t, ":")
If UBound(s) > 0 Then If Val(s(1)) > 59 Then s(1) = ""
If UBound(s) > 1 Then If Val(s(2)) > 59 Then s(2) = ""
If UBound(s) > 2 Then s(3) = "": flag = True
t = Join(s, ":")
t = Replace(t, "::", ":")
If flag Then t = Left(t, Len(t) - 1)
TextBox2 = t
Moyenne
End Sub
Sub Moyenne()
Dim s, t#
s = Split(TextBox2, ":")
If UBound(s) >= 0 Then t = Val(s(0))
If UBound(s) > 0 Then t = t + Val(s(1)) / 60
If UBound(s) > 1 Then t = t + Val(s(2)) / 1440
If t = 0 Then TextBox3 = "" Else _
TextBox3 = Format(Val(TextBox1) / t, "0.000") & " km/h"
End Sub