PC Review


Reply
Thread Tools Rate Thread

Convert 1 to "00001"?

 
 
Benson
Guest
Posts: n/a
 
      8th Feb 2007
Is there any easy way to convert an integer (eg. 1) to a embeded zero string
(eg. 00001)?

Benson
VB2005


 
Reply With Quote
 
 
 
 
Sergio E.
Guest
Posts: n/a
 
      8th Feb 2007
i think that the following 2 lines must do de trick

Dim s As String = String.Empty

s.PadLeft(5, "0"c)



Best regards,

Sergio E.



"Benson" <(E-Mail Removed)> escribió en el mensaje
news:%(E-Mail Removed)...
> Is there any easy way to convert an integer (eg. 1) to a embeded zero
> string (eg. 00001)?
>
> Benson
> VB2005
>



 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      8th Feb 2007
On 2007-02-08, Benson <(E-Mail Removed)> wrote:
> Is there any easy way to convert an integer (eg. 1) to a embeded zero string
> (eg. 00001)?
>
> Benson
> VB2005
>
>

Console.WriteLine (String.Format ("{0:00000}", 1))

HTH

--
Tom Shelton
 
Reply With Quote
 
gadgeteer
Guest
Posts: n/a
 
      8th Feb 2007
Or you could
Dim x As Int32 = 1Debug.Print(x.ToString("D5"))

"Benson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Is there any easy way to convert an integer (eg. 1) to a embeded zero
> string (eg. 00001)?
>
> Benson
> VB2005
>


 
Reply With Quote
 
Greg
Guest
Posts: n/a
 
      8th Feb 2007
"Benson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Is there any easy way to convert an integer (eg. 1) to a embeded zero
> string (eg. 00001)?


Dim i As Integer = 1
Dim s As String

s = i.ToString.PadLeft(5,"0")

Cheers.


 
Reply With Quote
 
gadgeteer
Guest
Posts: n/a
 
      8th Feb 2007
Was supposed to be 2 lines. Posted before I was finished editing.

Dim x As Int32 = 1
Debug.Print(x.To String("DO"))
 
Reply With Quote
 
gadgeteer
Guest
Posts: n/a
 
      8th Feb 2007
Spellchecker goofed up the code. I think you get the point but here it is
again just for grins.
Dim x As Int32 = 1

Debug.Print(x.ToString("D5"))


"gadgeteer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Was supposed to be 2 lines. Posted before I was finished editing.
>
> Dim x As Int32 = 1
> Debug.Print(x.To String("DO"))


 
Reply With Quote
 
Benson
Guest
Posts: n/a
 
      8th Feb 2007
Thanks all of you. I try String.Format ("{0:00000}", 1)) with success.

Benson.

"gadgeteer" <(E-Mail Removed)>
???????:11A8B473-F77A-4F1D-8863-(E-Mail Removed)...
> Spellchecker goofed up the code. I think you get the point but here it is
> again just for grins.
> Dim x As Int32 = 1
>
> Debug.Print(x.ToString("D5"))
>
>
> "gadgeteer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Was supposed to be 2 lines. Posted before I was finished editing.
>>
>> Dim x As Int32 = 1
>> Debug.Print(x.To String("DO"))

>



 
Reply With Quote
 
ClayB
Guest
Posts: n/a
 
      8th Feb 2007
Might as well make this comment too.

This syntax works as well.

1.ToString("000000")

==============
Clay Burch
Syncfusion, Inc.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? =?Utf-8?B?UGF1bCBK?= Microsoft Excel Programming 4 11th Jul 2007 11:32 AM
Display "00001" in a form field =?Utf-8?B?QWRhbQ==?= Microsoft Access Forms 3 10th Oct 2006 04:26 PM
LOTUS TRANSITION KEYS "/" "R" / "V" convert formulas to text. =?Utf-8?B?Ym9iQGdvcmRvbmVuZ2luZWVyaW5nLmNvbQ==?= Microsoft Access Getting Started 3 18th Jan 2006 09:15 AM
sending "works" email won't open.. needs "word"...can I convert =?Utf-8?B?d2hpdGVrbmlnaHRnb2xmbnV0?= Microsoft Access 1 28th Feb 2005 07:38 PM
counter does'nt count and stop at "00001" =?Utf-8?B?bWluZw==?= Microsoft Frontpage 7 19th Jan 2005 05:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:33 AM.