1 Divide By 2

D

DS

I have a field called Quantity...

If Quantity =1 and I divide by 2 I get 0
How do I get it to eual .5

Thanks
DS
 
D

DS

DS said:
Its Long Integer, I changed it to Decimal. Still Doesn't Work, What
should it be?
Thanks
DS
Ok That worked I changed it to Single. But I need it to Display .5 not
0.5 Thanks
DS
 
R

Randy Harris

DS said:
Its Long Integer, I changed it to Decimal. Still Doesn't Work, What
should it be?
Thanks
DS


Long Integer is not capable of storing fractional values (integer only).
Decimal is. Now you'll need to look at the other elements that Karl
suggested you examine.
 
D

DS

DS said:
Ok That worked I changed it to Single. But I need it to Display .5 not
0.5 Thanks
DS
Got it almost. I have this 1. 0r this .5, Is there any way to set the
format so that only if the number is less than 1 the decimal shows,
otherwise it would be just 1 not 1.
Thanks DS
 
D

Douglas J. Steele

Not using the Format property, nor the Format function.

If it's essential, you could write your own function along the lines of:

Function FormatNumber(ValueToFormat As Single) As String

Dim strFormatted As String

strFormatted = ValueToFormat
If ValueToFormat >= 1 Then
strFormatted = Replace(strFormatted, ".", "")
End If

FormatNumber = strFormatted

End Function
 
Top