Results 1 to 3 of 3

Thread: Nearest quarter hour

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Nearest quarter hour

    Hi,

    In the code below, LaborHours is a text box on the form.
    Is there a better way to do this?
    Code:
    If LaborHours - Int(LaborHours) <> Abs(0) And _
       LaborHours - Int(LaborHours) <> Abs(0.25) And _
       LaborHours - Int(LaborHours) <> Abs(0.5) And _
       LaborHours - Int(LaborHours) <> Abs(0.75) Then
        MsgBox ("Labor Hours must be to the nearest 1/4 hour.")
    End If
    Thanks,
    Al.
    A computer is a tool, not a toy.

  2. #2
    Fanatic Member Blade's Avatar
    Join Date
    Jan 1999
    Location
    Stoke-on-Trent, UK
    Posts
    527
    Hi,
    One way could be....

    VB Code:
    1. Select Case Right$(Format$(LabourHours,"0.00"),2)
    2.   Case "00","25","50","75"
    3.     Msgbox "OK"
    4.   Case Else
    5.     Msgbox "Not to nearest 1/4 hour"
    6. End Select

    Although I'm sure there may be better solutions out there!!

    Blade

  3. #3
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    You could just mutiply the labour hours by 4 and check if its a whole number :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width