Help with calculation of time

Final

New member
Joined
Jan 17, 2010
Messages
1
Programming Experience
Beginner
Hi, i want to calculate the difference in hours and minutes between 4:35:20 PM and 7:25:34 PM? how am i able to do this is vb.net?
 
VB.NET:
Dim d1, d2 As Date
If Date.TryParse("4:35:20 PM", d1) AndAlso Date.TryParse("7:25:34 PM", d2) Then
    Dim diff As TimeSpan = d2 - d1
    '
    MsgBox(diff.ToString)
    MsgBox(diff.TotalMinutes.ToString)
Else
    MsgBox("could not read one or both values")
End If
Date data type is represented by DateTime Structure (System)
TimeSpan Structure (System)
 
Back
Top