I would like to append 0 before a number if it is single digit. For example it should be 01,02,03... 09, 10, 11, ...
Use the apostrophe character You can type an apostrophe (') in front of the number, and Excel will treat it as text.
Use the "0"# format when you want to display one leading zero. When you use this format, the numbers that you type and the numbers that Microsoft Excel displays are listed in the following table. Example 2: Use the "000"# format when you want to display three leading zeros.
Zero (0) is used as a number and also as the numerical digit. Zero gives the additive identity of the integers, real numbers, and many algebraic structures. It is used as a placeholder for writing numbers. Natural numbers start from 1, then 2 and so on.
Dim yourNumber as Int32 = 5 yourNumber.ToString("D2") '= "05"
Try this:
myNum.ToString().PadLeft(2, "0");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With