Question time card calculator

adam lenz

New member
Joined
Jan 20, 2009
Messages
2
Programming Experience
1-3
hi i'm trying to create a program that when the user puts in the time they came to work and left work in this format (10:23 am) and convert it to a decimal such as (10.32) where 60 minutes gets spread into 100...

what i have is a form with text boxes for users to enter the time they came to work and left work, i want to be able to convert that to decimal and then total it up

if anyone has any ideas on how to do that it would be greatly appreciated.

Thanks!

Adam
 
VB.NET:
Dim start As String = "8:43 am"
Dim finish As String = "5:06 pm"
Dim startDate As Date
Dim finishDate As Date

If Date.TryParseExact(start, "h:mm tt", Nothing, Globalization.DateTimeStyles.None, startDate) AndAlso _
   Date.TryParseExact(finish, "h:mm tt", Nothing, Globalization.DateTimeStyles.None, finishDate) Then
    Dim workTime As TimeSpan = finishDate - startDate
    Dim hours As Double = workTime.Hours + workTime.Minutes / 60

    MessageBox.Show(hours.ToString("n2") & " Hours", "Work Time")
End If
Just be aware that, if shifts may start on one day and finish on the next, you'll have to make allowance for that.
 
3214941144_329d1dcf11_o.jpg


this is what my form looks like so far... would the code u gave me work with it?

does the way i arranged my form even work?

i wanna hit calculate and have it take the hours in the text boxes and display them in decimal time in the labels next to them

i wanna be able to hit total and have the number of hours worked totalled and put in the hours worked box at the bottom of the form
 
Back
Top