1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If InStr(TextBox1.Text, ":") = 0 Or InStr(TextBox1.Text, ":") = 0 Then
MsgBox("Veuillez écrire l'heure sous cette forme: hh:mm")
End If
If Len(TextBox1.Text) > 4 Or Len(TextBox2.Text) > 4 Then
MsgBox("Veuillez écrire l'heure sous cette forme: hh:mm")
End If
Dim un, deux, trois, quatre As Integer
Dim cinq, six As String
un = Mid(TextBox1.Text, 1, InStr(TextBox1.Text, ":") - 1)
deux = Mid(TextBox1.Text, InStr(TextBox1.Text, ":") + 1)
trois = Mid(TextBox2.Text, 1, InStr(TextBox2.Text, ":") - 1)
quatre = Mid(TextBox2.Text, InStr(TextBox2.Text, ":") + 1)
cinq = un - trois
six = deux - quatre
If cinq < 0 Then cinq = cinq * (-1)
If six < 0 Then six = six * (-1)
If Len(six) = 1 Then six = "0" & six
If Len(cinq) = 1 Then cinq = "0" & cinq
MsgBox(cinq & ":" & six)
End Sub |
Partager