Board index » Visual Studio » creating a string from a character and integer with leading zeros
|
kunalkapoor
|
|
kunalkapoor
|
creating a string from a character and integer with leading zeros
Visual Studio313
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 - |
| hirf-spam-me-here
Registered User |
Sun Jun 13 10:45:15 CDT 2004
Re:creating a string from a character and integer with leading zeros
* "Sameh Ahmed" <essoplus@hotmail.com>scripsit:
QuoteI have a couple of questions which I hope somebody will help me with. QuoteI also want to display an integer with leading zeros, with a defined length. Dim s As String = Format(43, "000000") /// -- Herfried K. Wagner [MVP] <URL:dotnet.mvps.org/>">dotnet.mvps.org/> - |
| Jay
Registered User |
Sun Jun 13 14:26:22 CDT 2004
Re:creating a string from a character and integer with leading zeros
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" <essoplus@hotmail.com>wrote in message QuoteHello there - |
