Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2005, 10:06 PM
Authorized User
 
Join Date: Aug 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default round up a decimal number

Can anyone help me HOW TO round up a decimal number up to 2 digits.

eg. from 1374.46 -------------> 1375.00

TQ in advance...

 
Old August 30th, 2005, 12:45 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

response.Write FormatNumber(round(1374.46),2,,,0)
This will round to 1374 and not 1375

Om Prakash
 
Old August 30th, 2005, 03:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ops sorry, I did not see the previous reply
Marco
 
Old October 4th, 2005, 02:33 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this function. It will take any number with a decimal after it, truncate it, and add one

    Public Shared Function roundUp(ByVal iNum As String) As Integer
        If Not IsDBNull(iNum) Then
            Dim sStr As String = iNum
            If InStr(sStr, ".") > 0 Then
                Return CInt(Left(iNum, InStr(sStr, ".") - 1)) + 1
            Else
                Return iNum
            End If
        Else
            Return 0
        End If
    End Function


mark






Similar Threads
Thread Thread Starter Forum Replies Last Post
Round up up to 2 decimal pt in crysatl Report prafullaborade VB How-To 0 September 26th, 2008 04:59 AM
Decimal place problem...ROUND function! kuku SQL Server 2000 9 July 9th, 2005 05:50 PM
Round to 2 decimal places adman JSP Basics 0 June 30th, 2005 07:24 AM
Round off the number in SQL haji_mb SQL Server ASP 1 May 2nd, 2005 07:37 AM
number of decimal? hosefo81 PHP How-To 1 February 11th, 2004 02:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.