473,386 Members | 1,743 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,386 software developers and data experts.

How to get leading zeros while conversion from integer to string

Jugmike
Hi
I want to have a format while conversion from integer to string i want that string has 5 digits and if integer has 3 digits only then it is represented like 00122. There is programming which i can do to achieve the same but just wanted to know if .net provides for the same
Thanks
Jugmike
Mar 27 '07 #1
1 1290
SammyB
807 Expert 512MB
Hi
I want to have a format while conversion from integer to string i want that string has 5 digits and if integer has 3 digits only then it is represented like 00122. There is programming which i can do to achieve the same but just wanted to know if .net provides for the same
Thanks
Jugmike
Yep, remember that in DotNet, everything is an object, so if you have an integer variable, n, then n.ToString("00000") gives you "00122".
Expand|Select|Wrap|Line Numbers
  1. Dim n As Integer = 122
  2. MsgBox(n.ToString("00000"))
Mar 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: david | last post by:
Hi, I have an application as follows: MySQL database Back-Eend linked to MS Access Front-End and ASP Web Application. I require users to enter Serial Numbers such as: 0105123567 (10...
8
by: TheTeapot | last post by:
Hi all, Here's a puzzle: // Say I have an array of numbers set up like so: $arr = array(15,16,17,100,121,1000); // How can I create a function so that I can use it like so:...
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: Sameh Ahmed | last post by:
Hello there I have a couple of questions which I hope somebody will help me with. First, in VBscript, I used to use the function "string", which will take an integer and a character, then creates...
6
by: Rich Raffenetti | last post by:
How can one format an integer into a hex string with leading zeros? Suppose an integer is 512 which in Hex is 200. I wish to print the 4-byte integer as 0200 or even 0x0200. The HEX function...
11
by: ram23 | last post by:
Hi friends, i need help .. i am getting String value and i need to add leading zeros.. total length of Target string is 13char eg: suppose if i get 12 as values.. it needs to convert into...
7
by: leninv | last post by:
Hi, I have the following code where 'recs' is a record set. For i=0 to recs.Fields.Count - 1 if i = 0 then pindnt = string(itmlvl*2," ") response.write pindnt &...
6
by: JimmyKoolPantz | last post by:
Task: Customer wants a script of the data that was processed in a "CSV" file. Problem: Zip-Code leading zeros are dropped Basically we have a client that has requested a custom script for...
5
n8kindt
by: n8kindt | last post by:
First of all, i haven't been to this site in a while and WOW is it much improved. I love all the new stuff--it looks great! I am all but done building a simple Point of Sale system through...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.