I am trying to round up numbers in a legacy application which I had coded in VB6 to obtain the following outcomes:
2.53 should be 2.60
2.55 should be 2.60
2.56 should be 2.60
2.50 should remain 2.50
I have tried to use the suggested User-Defined Rounding functions by Microsoft http://support.microsoft.com/kb/196652/en-gb
The closest I arrived to is the Asymup function
I am testing this procedure by calling the function as follows:Code:Function AsymUp(ByVal X As Double, _ Optional ByVal Factor As Double = 1) As Double Dim Temp As Double Temp = Int(X * Factor) AsymUp = (Temp + IIf(X = Temp, 0, 1)) / Factor End Function
But this is not producing the desired results because 2.60 for example becomes 2.7 when I want it to remain 2.6. Strangely enough 2.0 also becomes 2.1, implying that the function is not working well.Code:Text1.Text = AsymUp(Val(Text1.Text), 10)
How can I correct this to acheive the desired results




Reply With Quote
