VB 6 statement question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J Buchman

    VB 6 statement question

    I'm trying to write a statement in VB 6 that will give me the overtime pay. It needs to compute the first 40 hours at the normal pay rate, then any hours over 40 at rate * 1.5, then add those amount into a Datagrid field named "Gross". I can't get it to work correctly. I was trying to modify my statement for the regular hours to do it.
    fldRate is the pay rate, fldGross is gross pay and fldHours are the hours. My current statement is:

    If UCase(objFlds(" fldHours")) <= "40" Then
    objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e"), 2) ' normal work hours
    Else
    objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e") + _ ' overtime hours
    objFlds("fldHou rs") - 40 * objFlds("fldRat e") * 1.5, 2)
    End If


    Anyone have advice?


  • Rob Strover

    #2
    Re: VB 6 statement question

    Could you please explain, in some detail, the structure etc. of the variable 'objFlds'.

    Rob.
    "J Buchman" <jackbuchman@co mcast.net> wrote in message news:3K6dnYZUEv lRQNCiU-KYgg@comcast.co m...
    I'm trying to write a statement in VB 6 that will give me the overtime pay. It needs to compute the first 40 hours at the normal pay rate, then any hours over 40 at rate * 1.5, then add those amount into a Datagrid field named "Gross". I can't get it to work correctly. I was trying to modify my statement for the regular hours to do it.
    fldRate is the pay rate, fldGross is gross pay and fldHours are the hours. My current statement is:

    If UCase(objFlds(" fldHours")) <= "40" Then
    objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e"), 2) ' normal work hours
    Else
    objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e") + _ ' overtime hours
    objFlds("fldHou rs") - 40 * objFlds("fldRat e") * 1.5, 2)
    End If


    Anyone have advice?


    Comment

    • magician

      #3
      Re: VB 6 statement question

      Not sure about your objects and stuff but in pseudo code try:

      Gross = Hrs * PayRate
      If Hrs > 40 Then
      Gross = Gross + (Hrs - 40) * PayRate * .5
      End If

      This will give you the correct ammount for gross.
      Hope this helps :)
      "J Buchman" <jackbuchman@co mcast.net> wrote in message news:3K6dnYZUEv lRQNCiU-KYgg@comcast.co m...
      I'm trying to write a statement in VB 6 that will give me the overtime pay. It needs to compute the first 40 hours at the normal pay rate, then any hours over 40 at rate * 1.5, then add those amount into a Datagrid field named "Gross". I can't get it to work correctly. I was trying to modify my statement for the regular hours to do it.
      fldRate is the pay rate, fldGross is gross pay and fldHours are the hours. My current statement is:

      If UCase(objFlds(" fldHours")) <= "40" Then
      objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e"), 2) ' normal work hours
      Else
      objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e") + _ ' overtime hours
      objFlds("fldHou rs") - 40 * objFlds("fldRat e") * 1.5, 2)
      End If


      Anyone have advice?



      Comment

      • Kingbarry2000

        #4
        Re: VB 6 statement question

        >>>> If UCase(objFlds(" fldHours")) <= "40" Then
        Use numerics, not alpha
        try If val(objFlds("fl dHours")) <= 40 Then
        objFlds("fldGro ss") = Round(val(objFl ds("fldHours") ) * val(objFlds("fl dRate")), 2)
        Else
        objFlds("fldGro ss") = Round(val(objFl ds("fldHours") ) * val(objFlds("fl dRate")) + _
        val(objFlds("fl dHours")) - 40 * val(objFlds("fl dRate")) * 1.5, 2)

        "J Buchman" <jackbuchman@co mcast.net> wrote in message news:3K6dnYZUEv lRQNCiU-KYgg@comcast.co m...
        I'm trying to write a statement in VB 6 that will give me the overtime pay. It needs to compute the first 40 hours at the normal pay rate, then any hours over 40 at rate * 1.5, then add those amount into a Datagrid field named "Gross". I can't get it to work correctly. I was trying to modify my statement for the regular hours to do it.
        fldRate is the pay rate, fldGross is gross pay and fldHours are the hours. My current statement is:

        If UCase(objFlds(" fldHours")) <= "40" Then
        objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e"), 2) ' normal work hours
        Else
        objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e") + _ ' overtime hours
        objFlds("fldHou rs") - 40 * objFlds("fldRat e") * 1.5, 2)
        End If


        Anyone have advice?



        Comment

        • Travis Conway

          #5
          Re: VB 6 statement question

          I have too written software for calculating hours. It was in filePro, and
          not VB, but here would be a snippet of how I would do it:

          If val(objFlds("fl dHours")) <= 40 Then
          objFields("fldG ross") = Round(val(objFl ds("fldHours") ) *
          val(objFlds("fl dRate")), 2)
          Else

          objFields("fldG ross") = 40 * val(objFlds("fl dRate")) + _
          val(objFlds("fl dHours")) - 40 * ((val(objFlds(" fldRate")) * 1.5), 2)

          End If

          You calcuation on the first line of else needs to be set at 40, because if
          not, then if I worked 45 hours you are paying me for 45 at reg pay, and 5 at
          OT pay. On the second line of the else, You need to have it calc the OT Rate
          before you multiply it by the number of OT hours.


          --
          Travis Conway

          "Kingbarry2 000" <kingbarrypubli c@hotmail.com> wrote in message
          news:xZn3b.8641 58$3C2.19476393 @news3.calgary. shaw.ca...[color=blue][color=green][color=darkred]
          >>>> If UCase(objFlds(" fldHours")) <= "40" Then[/color][/color][/color]
          Use numerics, not alpha
          try If val(objFlds("fl dHours")) <= 40 Then
          objFlds("fldGro ss") = Round(val(objFl ds("fldHours") ) *
          val(objFlds("fl dRate")), 2)
          Else
          objFlds("fldGro ss") = Round(val(objFl ds("fldHours") ) *
          val(objFlds("fl dRate")) + _
          val(objFlds("fl dHours")) - 40 *
          val(objFlds("fl dRate")) * 1.5, 2)

          "J Buchman" <jackbuchman@co mcast.net> wrote in message
          news:3K6dnYZUEv lRQNCiU-KYgg@comcast.co m...
          I'm trying to write a statement in VB 6 that will give me the overtime pay.
          It needs to compute the first 40 hours at the normal pay rate, then any
          hours over 40 at rate * 1.5, then add those amount into a Datagrid field
          named "Gross". I can't get it to work correctly. I was trying to modify my
          statement for the regular hours to do it.
          fldRate is the pay rate, fldGross is gross pay and fldHours are the hours.
          My current statement is:

          If UCase(objFlds(" fldHours")) <= "40" Then
          objFlds("fldGro ss") = Round(objFlds(" fldHours") *
          objFlds("fldRat e"), 2) ' normal work hours
          Else
          objFlds("fldGro ss") = Round(objFlds(" fldHours") * objFlds("fldRat e")
          + _ ' overtime hours
          objFlds("fldHou rs") - 40 *
          objFlds("fldRat e") * 1.5, 2)
          End If


          Anyone have advice?


          Comment

          Working...