C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Round up amount


Posted Date: 11 Dec 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: Lalit Vasant PatilMember Level: Gold    
Rating: 1 out of 5Points: 10



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







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Round up amount  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Comma Separated Amount
Previous Resource: Convert Date Into Words
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use