View Full Version : Value gets rounded up


Jamet1234
11-29-2007, 05:33 PM
I am using code to fill in a text box on a form. In the code I am subtracting a variable Dim as long from a value from a textbox on the form. here is my code:

Dim lngDowntime As long
lngDowntime = DateDiff("n", Me.txtOrderDate, Me.txtDate_TimeCompleted) / 60
Me.txtDowntimeDiff = lngDowntime - Me.txtManhours

As you can see then I send the answer back to an other txt box on the form. This is the issue the answer in txtDowntimeDiff is incorrect because the value of ME.txtManhours is rounded up.

For example:

The dates for the DateDiff expresion return 408 hours
Me.txtManhours is 1.5
Me.txtDowntimeDiff should be 406.5
instead it returns 406.

Is there away to fix this?

Thanks
Anthony

RuralGuy
11-30-2007, 08:18 AM
Integers like Long only hold whole numbers. You will need to use a number that can hold a decimal value like Single of Double.