This might be a very basic question. I need to remove the zero before decimal point and print it that way. For example if I have 0.8 it should show .8
Asked
Active
Viewed 327 times
2 Answers
1
Use the formatting provided by the ToString method to clip away the integer part if it is 0
Dim x as Decimal = 0.8
Dim textToPrinto = x.ToString(".####")
(This keeps 4 decimals if present before rounding)

Steve
- 213,761
- 22
- 232
- 286
0
If you are using a StreamWriter or printing output to a file, then you can also use the Format statement. Format is used in a MsgBox example below (place in a Button command), which is identical for using in a sw or Print, Printline command.
Dim x As Double = 0.8
'You can remove zeroes after the decimal below
MsgBox(Format(x, ".0000"))
MsgBox(Format(x, ".0"))