Round up amount
Hi,
Below is function used to round up amount.
Function has two parameters : one is amount & second is amount round up digits.
Private Function RoundUpAmount(ByVal number As Double, ByVal digits As Integer) As Double
Dim Temp As String
Dim Temp2 As String
Dim i As Integer
Dim j As Integer
Dim ResultValue As Double
Dim Numbertemp As Double
Temp = Convert.ToString(number)
i = Temp.LastIndexOf(".")
If (((Temp.Length - (i + 1)) <= digits) Or (i = -1)) Then Return number
Temp2 = Temp.Substring(i + digits + 1, 1)
j = Convert.ToInt32(Temp2)
Numbertemp = Convert.ToDouble(Temp.Substring(0, i + digits + 1))
If j = 5 Then
ResultValue = Numbertemp + (1 / (Math.Pow(10, digits)))
Else
ResultValue = Math.Round(number, digits)
End If
Return ResultValue
End Function
e.g If i/p is
1. Response.Write(RoundUpAmount(133364.85566, 0))then o/p will be 133365
2. Response.Write(RoundUpAmount(133364.85566, 1))then o/p will be 133364.9
3. Response.Write(RoundUpAmount(133364.85566, 2))then o/p will be 133364.86
Try this