hi! im currently creating a payroll system for my project and part of it is a time calculator. but my problem sir is that i don't know how to deduct lates on there daily hour .. its goes this way sir, it has a textbox that has their schedule that is saved on the database and another textbox that contains their monthly rate and its also saved in a database now i created a text box that will contains the number of days in a month so i will just devide the number of days into theirs monthly rate so a can get their daily rate then i created a seven text boxes for a single day. the first txtbox is for the AM IN 2nd is for OUT 3rd is for PM IN 4th is for OUT the 5th is for the result of total hour in the AM and 6th is for the result of total hour in the PM and the 7th is for the total of 5th and 6th textbox and another textbox that will contain the earning for that day but i can only that accurately if i can deduct their lates on their schedule. w/c is their daily is deducted 1.16 per minute of lates and under time. this is the code i used on how will i get their working hour

 Dim d1 As DateTime
        Dim d2 As DateTime
        Dim ts11 As TimeSpan
        Dim ts22 As TimeSpan
        Dim tsfinal1 As TimeSpan

        TextBox9.Text = Val(SalTextBox.Text) / Val(TextBox8.Text)

        d1 = DateTime.Parse("1/1/2012 " + Me.TextBox1.Text.Trim)
        d2 = DateTime.Parse("1/1/2012 " + Me.TextBox2.Text.Trim)
        ts11 = d2 - d1

        TextBox5.Text = (ts11.ToString)


        d1 = DateTime.Parse("1/1/2012 " + Me.TextBox3.Text.Trim)
        d2 = DateTime.Parse("1/1/2012 " + Me.TextBox4.Text.Trim)
        ts22 = d2 - d1

        TextBox7.Text = (ts22.ToString)

        tsFinal1 = ts11 + ts22
        TextBox7.Text = tsfinal1.ToString





        im actualy trying this code to deduct their lates but i think i will need to do 2000 of line of this before i can finish.. 



 `Inline Code Example Here`If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:00" Then TextBox10.Text = Val(TextBox9.Text)
       If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:01" Then TextBox10.Text = Val(TextBox9.Text) - 1.16
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:02" Then TextBox10.Text = Val(TextBox9.Text) - 2.32
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:03" Then TextBox10.Text = Val(TextBox9.Text) - 3.48
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:04" Then TextBox10.Text = Val(TextBox9.Text) - 4.64
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:05" Then TextBox10.Text = Val(TextBox9.Text) - 5.8
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:06" Then TextBox10.Text = Val(TextBox9.Text) - 6.96
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:07" Then TextBox10.Text = Val(TextBox9.Text) - 8.12
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:08" Then TextBox10.Text = Val(TextBox9.Text) - 9.12
    If TimeValue(SkedTextBox.Text) = "8:00-5:00" And TimeValue(TextBox1.Text) = "8:09" Then TextBox10.Text = Val(TextBox9.Text) - 10.44  

Recommended Answers

All 6 Replies

put TextBox1.Text and 8:00 into a date and subtract. (datediff will give you the minutes).
If minutes are positive (eg 08:05 - 08:00 = 5 ) then multiply them by 1.16 or whatever. If they are negative then he's in early.

sir im getting the idea but can you please show me how to do that because im not realy good at vb and i don't know how will i do that.. thanks you sir..

Please note that I haven't tested the code below, so it may contain typos.

dim mins_late int 
mins_late =  datediff(n, DateTime.Parse("1/1/2012 " + Me.TextBox1.Text.Trim), "1/1/2012 08:00" )  
if mins_late < 0 then
mins_late = 0 
end if 
penalty = 1.16 * mins_late

thanks a lot sir.. ill try this.

sir what dimension should i put on the penalty. im sory sir i can't figure out whats wrong on the code.

Sorry for the late reply, I wasn't around lately. Is this still a problem?
What do you mean by dimension? penalty is a var (I know I didn't declare it, but still) I've used just to show you how you would get the "penalty" or as you've put it

w/c is their daily is deducted 1.16 per minute of lates and under time.

I guess you want to subtract this from textbox9 and display the result in textbox10.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.