Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do roundDown in VB

Status
Not open for further replies.

vbakan

MIS
Dec 6, 2006
24
GB
I want to round the decimal number to a hole number and it should always be just the hole number with out decimals

eg 23.34526 = 23
0.563 = 0
23.7335 = 23
 
Try something like this, the key part is WorksheetFunction, its 'calling' the standard Round function.

Dim myVal1 As Long
Dim myval2 As Integer

myVal1 = 23.5555

myval2 = Application.WorksheetFunction.Round(myVal1, 0)

MsgBox myval2

Cheers
 
pacmanUK
In my version, Round(23.7335)=24, not 23.
 
Apologies, When sending the response I read the text in the question rather than the title...

vbakan - try

application.worksheetfunction.rounddown(myval1,0)
 
pacmanUK
What have you got against Int?

Microsoft Help said:
INT
Rounds a number down to the nearest integer.

Syntax

INT(number)

Number is the real number you want to round down to an integer.

You can use it in VBA, VB.Net, VBScript ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top