473,396 Members | 2,158 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,396 software developers and data experts.

creating a string from a character and integer with leading zeros

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 a string of the character with the
integer as the length of this string.
Need to do the same with VB.net.
I also want to display an integer with leading zeros, with a defined length.
Example, 43 appears as 00043 when the length is 5 and 000043 when the length
is 6.
Any ideas will be appreciated.
Regards
Sameh
Nov 20 '05 #1
2 14231
* "Sameh Ahmed" <es******@hotmail.com> scripsit:
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 a string of the character with the
integer as the length of this string.
Need to do the same with VB.net.
It's called 'StrDup' in VB.NET.
I also want to display an integer with leading zeros, with a defined length.
Example, 43 appears as 00043 when the length is 5 and 000043 when the length
is 6.


\\\
Dim s As String = Format(43, "000000")
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Sameh,
In addition to the Format function. You can use Integer.ToString to have the
same the same effect.

Dim i As Integer = 45
Dim s As String
s = i.ToString("D5")
s = i.ToString("D4")

Hope this helps
Jay

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:el*************@TK2MSFTNGP11.phx.gbl...
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 a string of the character with the
integer as the length of this string.
Need to do the same with VB.net.
I also want to display an integer with leading zeros, with a defined length. Example, 43 appears as 00043 when the length is 5 and 000043 when the length is 6.
Any ideas will be appreciated.
Regards
Sameh

Nov 20 '05 #3

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

Similar topics

2
by: Todd_M | last post by:
I was wondering what anyone might suggest as "best practice" patterns for streaming out fixed formatted text files with C#? Let's say we get our data in a dataset table and we need to iterate over...
4
by: Brian Henry | last post by:
Say I have a text string like "0002323235-3434-3545" and I want to remove the leading zeros, would a regular expression work here? sorry I haven't worked with regex's that much and still need to...
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...
10
by: klineb | last post by:
Good Day, I have written and utility to convert our DOS COBOL data files to a SQL Server database. Part of the process requires parsing each line into a sql statement and validting the data to...
19
by: Robbie Hatley | last post by:
For your enjoyment, a function that expresses any integer with absolute value less-than-or-equal-to nine quintillion in any base from 2 to 36. (For larger bases, you could expand the "digit"...
30
by: ceeques | last post by:
Hi I am a novice in C. Could you guys help me solve this problem - I need to convert integer(and /short) to string without using sprintf (I dont have standard libray stdio.h). for...
13
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I...
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...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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.