Private Sub CommandButton2_Click()
Dim deb As Date, fin As Date, Tempdeb As Double, Tempfin As Double
Dim DecSep, plageTemp As Double, plageDate
DecSep = Mid(Evaluate("1 / 2"), 2, 1)
If DecSep = "," Then DecSep = "la Virgule" Else DecSep = "le Point"
TextBox5 = "": TextBox6 = ""
On Error GoTo Err_deb
deb = CDate(TextBox2)
If deb - Fix(deb) <= 0.000000001 Then GoTo Err_deb
On Error GoTo Err_fin
fin = CDate(TextBox3)
If fin - Fix(fin) <= 0.000000001 Then GoTo Err_fin
On Error GoTo Err_Tempdeb
Tempdeb = CDbl(TextBox7)
On Error GoTo Err_Tempfin
Tempfin = CDbl(TextBox4)
On Error GoTo 0
If deb >= fin Then
MsgBox "la date de début est supérieure ou égale à la date de fin => calcul impossible"
Exit Sub
Else
plageTemp = (Tempfin - Tempdeb)
plageDate = (fin - deb) * 24# * 3600#
TextBox5 = Format(plageTemp / plageDate * 3600, "0.000")
TextBox6 = Format(plageTemp / plageDate * 60, "0.000")
End If
Exit Sub
'---------------------------------------------------------------------
Err_deb:
MsgBox "Le format de la date de début est erroné." & _
" Veuillez saisir la date sous la forme: jj/mm/aaaa hh:mm:ss"
TextBox2.SetFocus
TextBox2.SelStart = Len(TextBox2)
Exit Sub
Err_fin:
MsgBox "Le format de la date de fin est erroné." & _
" Veuillez saisir la date sous la forme: jj/mm/aaaa hh:mm:ss"
TextBox3.SetFocus
TextBox3.SelStart = Len(TextBox3)
Exit Sub
Err_Tempdeb:
MsgBox "Le format de la température de début est erroné." & _
" Veuillez saisir la température sous la forme d'un nombre avec comme séparateur décimal : " & DecSep
TextBox7.SetFocus
TextBox7.SelStart = Len(TextBox7)
Exit Sub
Err_Tempfin:
MsgBox "Le format de la température de fin est erroné." & _
" Veuillez saisir la température sous la forme d'un nombre avec comme séparateur décimal : " & DecSep
TextBox4.SetFocus
TextBox4.SelStart = Len(TextBox4)
Exit Sub
End Sub