473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how add zeros to numbers...

hello...
i have a number which i want to add 0's to it..

e.g.
int number = 002;
number = number + 1 and it should return me e.g. 3.
how can i keep the 002 and allow it to return 003 instead of just 3?

thanks.

Nov 19 '05 #1
3 1233
Hi Asha,

Try this?

int number = 002;
number = number + 1;
Label1.Text=number.ToString("000");

Ken
Microsoft MVP [ASP.NET]
Toronto

"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
hello...
i have a number which i want to add 0's to it..

e.g.
int number = 002;
number = number + 1 and it should return me e.g. 3.
how can i keep the 002 and allow it to return 003 instead of just 3?

thanks.


Nov 19 '05 #2
Here's a reference for the format strings:

http://msdn.microsoft.com/library/de...putexample.asp
"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
hello...
i have a number which i want to add 0's to it..

e.g.
int number = 002;
number = number + 1 and it should return me e.g. 3.
how can i keep the 002 and allow it to return 003 instead of just 3?

thanks.


Nov 19 '05 #3
You don't have a number. You have a string. In numbers, 002 IS 2. There are
no leading zeros. There are only bits. A 32-bit integer, for example, has 32
bits, all of which are either 1 or 0.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
hello...
i have a number which i want to add 0's to it..

e.g.
int number = 002;
number = number + 1 and it should return me e.g. 3.
how can i keep the 002 and allow it to return 003 instead of just 3?

thanks.

Nov 19 '05 #4

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

Similar topics

5
by: samik_tanik | last post by:
I need to export a datagrid to Excel. I could did this. But, also need to keep the leading zeros in the data. How can I acheive this? Any help would be appreciated. -- Thanking you in...
5
by: samik_tanik | last post by:
I need to export a datagrid to Excel. I could did this. But, also need to keep the leading zeros in the data. How can I acheive this? Any help would be appreciated. -- Thanking you in...
2
by: chris | last post by:
Hi, I have a simple ms access application that allows you to scan barcodes in to a form which stores them in the database. The barcodes are 6 digits in length e.g. 555666 but my handheld...
9
by: Chester | last post by:
I'm working on an app that records data collected by service technicians (VB.Net front-end, SQL Server 2000 back end). The technicians need to record numbers with varying scale and precision. For...
3
by: ManuelValdez | last post by:
Hello everybody! I need your valuable help to get an Excel macro to delete the single zeros only and no the zeros containing numbers like 360, 90, etc., because if I chose the search and replace...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.