I need to truncate the amount of decimal places of my double value for display in a textbox. How would one achieve this with vba?
You can use Int() function. Debug.print Int(1.99543)
Debug.print Int(1.99543)
Or Better:
Public Function Trunc(ByVal value As Double, ByVal num As Integer) As Double Trunc = Int(value * (10 ^ num)) / (10 ^ num) End Function
So you can use Trunc(1.99543, 4) ==> result: 1.9954
Trunc(1.99543, 4)
result: 1.9954