473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

printing a zero

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.
Oct 13 '06 #1
3 1029
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
"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.
Oct 13 '06 #2
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

Oct 13 '06 #3

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")

Oct 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Daniel Pryde | last post by:
Hi there. I hope this isn't a stupid question to ask, but does anyone know how to print out a string without moving to a new line each time and simply updating the first line. An example would be,...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
11
by: jt | last post by:
Here is my code below, it doesn't printf. But I step it thru using the for statement and use putchar to the display, its there... How can I get it to use printf? If the problem is needing a null...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
1
by: Gary Wessle | last post by:
Hi I am expecting to get "0" (that is zero) printed but getting "-2.7311e-14" almost zero. not nice for printing. double a = \*...code calculations ...*\ some times a becomes a real, integer...
9
by: junky_fellow | last post by:
Hi, To print the pointer using printf(), we convert it to (void *) . printf("%p",(void *)ptr); My question is how printf() determine which type of pointer is passed to it and prints its value...
8
by: Microsoft News | last post by:
Greetings community at large. I have a c# app that generates a PDF file. I have a printer that prints PDF natively. But I cannot figure out how to programatically print in C# ... I can...
5
by: Xah Lee | last post by:
If i have a nested list, where the atoms are unicode strings, e.g. # -*- coding: utf-8 -*- ttt=, ,...] print ttt how can i print it without getting the u'\u1234' notation? i.e. i want it...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.