Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to format this string automatically using vb.net
VB
Dim stext as string ="1A"
Dim stext1 as string ="A1"
Dim sout,sout1 As String
sout= String.Format("0000", stext )
sout1 = String.Format("0000", stext1 )


but iam getting output as :

stext = 0000
stext1= 0000


But i need an output as :
stext=001A
stext1=00A1

Kinldy do the needfull
Posted
v2

VB
sout = "00" + stext;
sout1 = "00" + stext1;
 
Share this answer
 
Have a look here: How to: Pad a Number with Leading Zeros[^]
And even better way is to create custom format provider: How to: Define and Use Custom Numeric Format Providers[^]
 
Share this answer
 
v2
VB
Dim yourNumber as Int32 = 5
yourNumber.ToString("D2") '= "05"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900