Home All Groups Group Topic Archive Search About
Author
13 Oct 2006 8:09 PM
Candace
I have a program that performs calculations and displays a four digit number.
Sometimes the calculation results in a number like 0854, but my program
displays it as 854. How can I force the program to display the leading zero,
when the first digit is a zero? I'm only dealing with the integer data type.

Author
13 Oct 2006 8:12 PM
Dylan Copeland
Instead of using integers you could use a string and determine if the string
is shorter than 4 characters long. If it was shorter you could just add a
zero in front of the string.
---------------
-Dylan Copeland
http://www.dc-studios.net
http://www.vbdotnetforum.com


Show quoteHide quote
"Candace" wrote:

> I have a program that performs calculations and displays a four digit number.
> Sometimes the calculation results in a number like 0854, but my program
> displays it as 854. How can I force the program to display the leading zero,
> when the first digit is a zero? I'm only dealing with the integer data type.
Author
13 Oct 2006 8:25 PM
Josip Medved
> Sometimes the calculation results in a number like 0854, but my program
> displays it as 854. How can I force the program to display the leading zero,
> when the first digit is a zero? I'm only dealing with the integer data type.

number.ToString("0000")

--
Greetings,
  Josip Medved
  http://www.jmedved.com
Author
13 Oct 2006 8:30 PM
zacks
Candace wrote:
> I have a program that performs calculations and displays a four digit number.
> Sometimes the calculation results in a number like 0854, but my program
> displays it as 854. How can I force the program to display the leading zero,
> when the first digit is a zero? I'm only dealing with the integer data type.

..ToString("0000")