I want to display 3 decimal places when outputting the value of a double even if it has trailing zeroes. For instance, if I have s = 3.400 and I use Debug.Print(s), I only get 3.4 displayed. How can I format the output?
I want to display 3 decimal places when outputting the value of a double even if it has trailing zeroes. For instance, if I have s = 3.400 and I use Debug.Print(s), I only get 3.4 displayed. How can I format the output?
Last edited by 6StringJazzer; 11-01-2018 at 02:29 PM. Reason: Updated title to workaround forum bug when last word of subject is "print"
where d is your variable or expressionPlease Login or Register to view this content.
Thank you, Jeff!
When using that code within VBA, I get a compile error on Format. Does it need something else included?
No. What is your compile error? Can you show the code?
Here is the exact code I used to confirm it.
output:Please Login or Register to view this content.
Please Login or Register to view this content.
Really odd. I copied your line, but I'm using my variable which is a double and it changes the word Format to format and then doesn't compile. Here is my code...
Please Login or Register to view this content.
Nevermind. I see the problem. I have two variables with the same name.
Yes, Format is a built-in function. It is not a good idea to name variables after any predefined values or built-in functions.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks