add leading zero

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

In VB.Net,

How do I take a number such as 99 and convert it to 099?

I have a number from a DataTable named dr.Item(1) (dr being a datarow), that
I need to convert to a string with leading zeros. It needs to be 3 chars
long.

Thanks,

Tom
 
some ideas...

Function ThreeDigit(ByVal x As Integer) As String
Return x.ToString.PadLeft(3, "0"c)
'Return Microsoft.VisualBasic.Right("00" & x.ToString, 3)
End Function

Greg
 
Greg Burns said:
some ideas...

Function ThreeDigit(ByVal x As Integer) As String
Return x.ToString.PadLeft(3, "0"c)
'Return Microsoft.VisualBasic.Right("00" & x.ToString, 3)
End Function

Worked great.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top